You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Recursive type definition produces unexpected error message #7125
[case testRecursiveNamedTupleTypedDict2]
# flags: --new-semantic-analyzer
import a
[file a.py]
import lib
x: int
[file a.py.2]
import lib
x: lib.A
reveal_type(x.x['x'])
[file lib.pyi]
from typing import NamedTuple
from other import B
A = NamedTuple('A', [('x', B)])
[file other.pyi]
from mypy_extensions import TypedDict
from lib import A
B = TypedDict('B', {'x': A})
[builtins fixtures/dict.pyi]
Here's the output:
tmp/lib.pyi:2: error: Module 'other' has no attribute 'B'
I'd expect there to be an error about a cyclic definition instead.
There is an existing test case testRecursiveNamedTupleTypedDict in check-incremental.test that triggers the error. The above test case is slightly simplified version of that test case.
Activity
AlexWaygood commentedon Jun 18, 2022
The error message is now slightly different, but still seems bad:
ilevkivskyi commentedon Aug 23, 2022
I don't think this is relevant anymore, the test passes with
--enable-recursive-aliases.