discord.py stubs
Project description
discord.py-stubs
This package contains type stubs to provide more precise static types and type inference for discord.py.
Installation
pip install discord.py-stubs
NOTE: Because discord.py
uses namespace packages for its extensions, mypy
must be configured to use namespace packages either with the --namespace-packages
command line flag, or by setting namespace_packages = True
in your mypy
configuration file. See the import discovery section of the mypy
documentation for more details.
Usage Notes
In most cases, installing this package will enable developers to type check their discord.py bots using mypy out of the box. However, if developers wish to subclass the classes in discord.ext.commands
they will need to follow the mypy
documentation outlining how to use classes that are generic in stubs but not at runtime:
from typing import TYPE_CHECKING
from discord.ext import commands
class MyContext(commands.Context):
...
if TYPE_CHECKING:
Cog = commands.Cog[MyContext]
else:
Cog = commands.Cog
class MyCog(Cog):
...
In order to avoid this issue, developers can use discord-ext-typed-commands
:
from discord.ext import typed_commands
class MyContext(typed_commands.Context):
...
class MyCog(typed_commands.Cog[MyContext]):
...
Development
Make sure you have poetry installed.
poetry install
poetry run pre-commit install --hook-type pre-commit --hook-type post-checkout
Version numbering scheme
At this time, the version number of discord.py-stubs
will follow the version number of discord.py
it corresponds to and append one more version segment that indicates the sequence of releases for the stubs. For instance, if you are using discord.py
version 1.3.4
, you would use discord.py-stubs
version 1.3.4.X
where X
is an integer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for discord.py_stubs-1.5.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 584158775e7d9ddcd58cc63d4fea640c85ac6a8d6d21ac1621edd9f99154a52e |
|
MD5 | 0d44f6ffeb781a490f232f7221d7d14d |
|
BLAKE2b-256 | ef2a2e3d817ff9f219ad0653a129d63e0d631f85b514b9a7fbd9515a3a2044e5 |