Skip to content

"Can't determine type" error in import cycles with named tuples and typed dicts #5658

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

Closed
ilevkivskyi opened this issue Sep 21, 2018 · 1 comment

Comments

@ilevkivskyi
Copy link
Member

ilevkivskyi commented Sep 21, 2018

Consider this test case which currently fails with Cannot determine type of "tp":

[case testNamedTupleImportCycle]
import b
[file a.py]
class C:
    pass

from b import tp
reveal_type(tp)  # Cannot determine type of 'tp'
tp('x')  # Cannot determine type of 'tp'

[file b.py]
from a import C
from typing import NamedTuple

tp = NamedTuple('tp', [('x', int)])
[out]

Note however that such code will anyway fail at runtime, and it works if one imports under if MYPY: (see #2015). I think therefore it is relatively low priority.

This is a follow up for #5635

@ilevkivskyi
Copy link
Member Author

This works correctly on master (likely fixed by the new semantic analyzer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants