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