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
The major and minor version numbers of discord.py-stubs
will match the major and minor version numbers of the discord.py
release the stubs represent. For instance, if you are using discord.py
version 1.7.4
, you would use discord.py-stubs
version 1.7.X
where X
is the latest patch version of the stubs. Using semver dependency specifications, discord.py-stubs
version ~1.7
is designed to work with discord.py
version ~1.7
.
In addition, discord.py-stubs
will indicate which versions of the runtime library are compatible through its dependency information (as suggested in PEP-561).
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
File details
Details for the file discord.py-stubs-1.7.3.tar.gz
.
File metadata
- Download URL: discord.py-stubs-1.7.3.tar.gz
- Upload date:
- Size: 44.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d28d218540217794ff12b7c0afd8ee4d65fc91bd169c53475781ac99413819ec |
|
MD5 | 5b09648de4f4f8d0ff4e976c0c3a4456 |
|
BLAKE2b-256 | 41f23ac03d1270079c86a60e7677c402564144439e890b5873dbe146032e24e0 |
File details
Details for the file discord.py_stubs-1.7.3-py3-none-any.whl
.
File metadata
- Download URL: discord.py_stubs-1.7.3-py3-none-any.whl
- Upload date:
- Size: 63.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec6283e08beff4660c2d28a3fb48f501eb74988d8d6e5859b3838ac897016c95 |
|
MD5 | 3299a2b707b9c4d0ba88b9462d3b843c |
|
BLAKE2b-256 | 455110e21662776254ba3e721c64413a910596c90d9c237bae50c1f1f37e50c7 |