Organize special forms in typing (#3966)

This is an accompanying PR for https://github.com/python/mypy/pull/8779, see https://github.com/python/mypy/pull/8779#issuecomment-624001349

I also noticed that Python 2 and Python 3 versions are a bit out of sync, so I also put them back in sync.
This commit is contained in:
Ivan Levkivskyi
2020-05-05 13:55:31 +01:00
committed by GitHub
parent d818821121
commit 8c7f489d1b
2 changed files with 13 additions and 14 deletions

View File

@@ -14,8 +14,10 @@ TypeVar = object()
_promote = object()
class _SpecialForm:
def __getitem__(self, typeargs: Any) -> Any: ...
def __getitem__(self, typeargs: Any) -> object: ...
Union: _SpecialForm = ...
Optional: _SpecialForm = ...
Tuple: _SpecialForm = ...
Generic: _SpecialForm = ...
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
@@ -61,8 +63,6 @@ class _Alias:
# Class for defining generic aliases for library types.
def __getitem__(self, typeargs: Any) -> Any: ...
Union = _Alias()
Optional = _Alias()
List = _Alias()
Dict = _Alias()
DefaultDict = _Alias()