-
-
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-0-hightopic-import-cycles
Description
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" <---- unexpectedt2.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.
abesto
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-import-cycles