-
-
Notifications
You must be signed in to change notification settings - Fork 482
Closed
Labels
unconfirmed bugA bug report that needs triagingA bug report that needs triaging
Description
Summary
Mypy errors when using pycord with namespace_packages flag enabled
Reproduction Steps
Run mypy against a simple pycord setup.
An example set up is as follows:
my-repo/
├─ my_bot/
│ ├─ bot.py
.mypy.ini
Run mypy via: mypy my_bot/
Mypy config:
[mypy]
namespace_packages = True
ignore_missing_imports = True
Minimal Reproducible Code
`from discord import ApplicationCommand` in bot.py
Expected Results
Type checking works as expected with namespace_packages
enabled
Actual Results
Type checking errors with:
virtual-env-path/lib/python3.9/site-packages/discord/commands/__init__.py: error: Source file found twice under different module names: "discord.commands.__init__" and "discord.commands"
Found 1 error in 1 file (errors prevented further checking)
Intents
N/A
System Information
- Python v3.9.5-final
- py-cord v2.0.0-beta
- py-cord pkg_resources: v2.0.0b3
- aiohttp v3.8.1
- system info: Darwin 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
Mypy won't error is namespace_packages
is False
but then it cannot infer the types properly and will result in errors such as:
app/bot.py:1: error: Module "discord" has no attribute "ApplicationCommand"; maybe "ApplicationCommandMixin"?
This issue is also persistent in nextcord however, nextcord is available under discord
and nextcord
so in nextcord
this issue is fixed by changing the import to from nextcord import ApplicationCommand
. Pycord doesn't expose the package as pycord
. Any reason for this?.
Defelo
Metadata
Metadata
Assignees
Labels
unconfirmed bugA bug report that needs triagingA bug report that needs triaging