Closed
Description
- Are you reporting a bug, or opening a feature request?
Bug.
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
This requires two modules to trigger the bug:
dummy.py:
from typing import Type, TypeVar, Callable
T = TypeVar('T')
ImplementationFactory = Callable[[Type[T]], T]
MyFactory = ImplementationFactory[str] # Works fine
dummy2.py:
import dummy
MyFactory2 = dummy.ImplementationFactory[str]
- What is the actual behavior/output?
$ mypy dummy2.py
dummy2.py:4: error: Name 'T' is not defined
Note that line 4 is empty. You can also add comments to get a different line number displacement. Also note that T
is never referred to in dummy2
.
- What is the behavior/output you expect?
I would expect no errors for this code.
- What are the versions of mypy and Python you are using?
$ mypy --version
mypy 0.711
$ python --version
Python 3.7.3
- Do you see the same issue after installing mypy from Git master?
I didn't try.
- What are the mypy flags you are using? (For example --strict-optional)
None. The command line is shown in full, there is no config file.