Closed LEv145 closed 5 months ago
I doubt there's anything we can do about this, unfortunately. PyCharm has been struggling to infer descriptor types (especially generic ones) correctly for a long time, and ultimately it's up to them to fix it - disnake isn't the only library affected by this. There are several open issues that are more or less related:
Mypy and Pyright can handle these just fine, so those might be your best bet for now.
Thanks!
One of the possible solutions in PyCharm:
@commands.slash_command()
async def ping(self, inter: disnake.CommandInteraction) -> None:
assert isinstance(inter.response, disnake.InteractionResponse)
await inter.response.send_message("Pong!")
Or
@commands.slash_command()
async def ping(self, inter: disnake.CommandInteraction) -> None:
inter.response: disnake.InteractionResponse # type: ignore
await inter.response.send_message("Pong!")
This should probably be closed?
Summary
Pycharm does not recognize type, which is why the method hints are not displayed
Reproduction Steps
Write code:
Minimal Reproducible Code
No response
Expected Results
Type-based hints
Actual Results
Lack of hints
Intents
Intents.default()
System Information
Checklist
Additional Context
Pycharm
bug report: https://youtrack.jetbrains.com/issue/PY-63737/PyCharm-fails-to-infer-generic-descriptor-type-when-descriptor-is-used-as-a-decoratorPylance
works correctly (VSCode
)