pyright icon indicating copy to clipboard operation
pyright copied to clipboard

Type could not be determined because it refers to itself

Open augustelalande opened this issue 4 months ago • 1 comments

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 avatar Oct 03 '24 01:10 augustelalande