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

Recursive type definition produces unexpected error message #7125

Closed
JukkaL opened this issue Jul 2, 2019 · 2 comments
Closed

Recursive type definition produces unexpected error message #7125

JukkaL opened this issue Jul 2, 2019 · 2 comments
Labels
bug mypy got something wrong priority-1-normal semantic-analyzer Problems that happen during semantic analysis topic-recursive-types topic-usability

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 2, 2019

This test cases produces unexpected output:

[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.

@AlexWaygood
Copy link
Member

The error message is now slightly different, but still seems bad:

tmp/other.pyi:2: error: Module "lib" has no attribute "A"

@ilevkivskyi
Copy link
Member

I don't think this is relevant anymore, the test passes with --enable-recursive-aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal semantic-analyzer Problems that happen during semantic analysis topic-recursive-types topic-usability
Projects
None yet
Development

No branches or pull requests

4 participants