Type checking the following files results in an unexpected "Invalid type" error:
t.py:
MYPY = False
if MYPY:
from t2 import A
x: A # Invalid type "t2.A" <---- unexpected
t2.py:
import t
from typing import Callable
A = Callable[[], None]
The reason for the error is that t and t2 form an import cycle and t is processed before t2 in the cycle, and thus the type alias A hasn't been processed when we analyze t.
This is probably the same bug as #4442, but for users this may not be obvious, so it perhaps makes maintain a separate issue.
Type checking the following files results in an unexpected "Invalid type" error:
t.py:t2.py:The reason for the error is that
tandt2form an import cycle andtis processed beforet2in the cycle, and thus the type aliasAhasn't been processed when we analyzet.This is probably the same bug as #4442, but for users this may not be obvious, so it perhaps makes maintain a separate issue.