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

Type could not be determined because it refers to itself #9139

Closed
augustelalande opened this issue Oct 3, 2024 · 2 comments
Closed

Type could not be determined because it refers to itself #9139

augustelalande opened this issue Oct 3, 2024 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@augustelalande
Copy link

I'm not sure I can describe what's happening better than just sharing the code.

MRE:

from enum import StrEnum


class Foo(StrEnum):
    A = "A"


for _ in range(2):
    baz: dict[Foo, int] = {}

    if Foo.A in baz:
        ...

    for _ in baz.values():
        ...

Output:

➜ pyright --version
pyright 1.1.383

➜ pyright .\bug.py
c:\Users\Auguste\workspace\test\bug\bug.py
  c:\Users\Auguste\workspace\test\bug\bug.py:11:17 - error: Type of "baz" could not be determined because it refers to itself (reportGeneralTypeIssues)
  c:\Users\Auguste\workspace\test\bug\bug.py:14:14 - error: Type of "baz" could not be determined because it refers to itself (reportGeneralTypeIssues)
2 errors, 0 warnings, 0 informations
@augustelalande augustelalande added the bug Something isn't working label Oct 3, 2024
@erictraut
Copy link
Collaborator

Thanks, I'm able to repro the problem and will investigate further.

erictraut added a commit that referenced this issue Oct 24, 2024
…mined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code. This addresses #9139.
erictraut added a commit that referenced this issue Oct 24, 2024
…mined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code. This addresses #9139. (#9323)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Oct 24, 2024
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.387.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants