-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normalsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-import-cycles
Description
This may be a duplicate issue, but I'm a bit lost... I'm using mypy 0.600 and Python 3.6.2.
# a.py
from typing import Union
from c import T
class A:
x: str
class B:
x: str
U = Union[A, B]
# b.py
from c import U
def foo(u: U):
print(u.x)
# c.py
class T:
pass
from a import U
from b import foo
python -c 'import c' works, Mypy . give the errors:
b.py:3: error: Invalid type "a.U"
b.py:4: error: U? has no attribute "x"
I would like to understand how here Mypy import mechanism is different from Python import mechanism, and why Mypy fails with U type.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normalsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-import-cycles