Skip to content

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

Closed
@Wizzerinus

Description

@Wizzerinus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy