Guido van Rossum added the comment: You've hit a type where PEP 484 and mypy disagree.
The PEP shows a few examples of this: https://www.python.org/dev/peps/pep-0484/#instantiating-generic-classes-and-type-erasure However when I feed the examples from the PEP to mypy I get an error on each of the last two lines: ----- from typing import TypeVar, Generic T = TypeVar('T') class Node(Generic[T]): pass x = Node[T]() y = Node[int]() ----- b.py:5: error: Invalid type "b.T" b.py:5: error: Generic type not valid as an expression any more (use '# type:' comment instead) b.py:6: error: Generic type not valid as an expression any more (use '# type:' comment instead) I suspect that mypy is right and the PEP didn't catch up to the change of mind in the flurry of activity right before acceptance. Since it's provisional I'd like to change the PEP to disallow this. At the same time at runtime I think it should either fail loudly or work, not silently return an uninitialized instance, so typing.py also needs to be fixed. Thanks for the report! ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26391> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com