Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Pyright cannot determine type of bot attribute on extensions as it thinks Client derives from itself #1747

Open
4 tasks done
Wizzerinus opened this issue Jan 2, 2025 · 0 comments

Comments

@Wizzerinus
Copy link
Contributor

Wizzerinus commented Jan 2, 2025

Library Version

5.13.2

Describe the Bug

I've noticed Pyright and Mypy both cannot determine the type of ext.bot. After a bit of analysis, it actually seems Pyright cannot determine type of Client attributes at all. For example, the output on the file provided below is as follows:

❯ mypy discordbot/discordbot/features/ext_base.py
discordbot/discordbot/features/ext_base.py:8: note: Revealed type is "interactions.client.client.Client"
Success: no issues found in 1 source file
❯ pyright discordbot/discordbot/features/ext_base.py
.../discordbot/discordbot/features/ext_base.py
  .../discordbot/discordbot/features/ext_base.py:8:21 - information: Type of "self.c" is "Unknown"
0 errors, 0 warnings, 1 information 

And they both fail to derive type of Extension.bot, at the same time Extension.name and such are properly derived:

from interactions import Extension


class M(Extension):
    def run(self):
        reveal_type(self.bot)
        reveal_type(self.name)
❯ mypy discordbot/discordbot/features/ext_base.py
discordbot/discordbot/features/ext_base.py:6: note: Revealed type is "Any"
discordbot/discordbot/features/ext_base.py:7: note: Revealed type is "builtins.str"
Success: no issues found in 1 source file
❯ pyright discordbot/discordbot/features/ext_base.py
.../discordbot/discordbot/features/ext_base.py
  .../discordbot/discordbot/features/ext_base.py:6:21 - information: Type of "self.bot" is "Unknown"
  .../discordbot/discordbot/features/ext_base.py:7:21 - information: Type of "self.name" is "str"
0 errors, 0 warnings, 2 informations

I've also tried to check the file client.py itself with both Mypy and Pyright. I could not get a lot from Mypy testing because it breaks as the file is located nearby a mypy_extensions folder :( but Pyright says the class Client derives from itself on every single mixin of that class, which is very bizarre and unlike any issue I've seen before. Renaming the class Client to Client0 actually fixed the issue for some reason, so there's something fishy going on there.

Steps to Reproduce

  1. attempt to check the file below with Pyright, or to reveal_type on ext.bot with either Pyright or Mypy.
  2. Observe the error.

Expected Results

type is properly checked

Minimal Reproducible Code

from interactions import Client


class M:
    c: Client

    def run(self):
        reveal_type(self.c)   # pyright says Unknown!
                              # mypy is fine with this though, but has a different bug, see above

Traceback

No response

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.
  • I have attempted to debug this myself, and I believe this issue is with the library

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant