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

@@ -15,6 +15,8 @@ _promote = object()
class _SpecialForm(object):
def __getitem__(self, typeargs: Any) -> object: ...
Union: _SpecialForm = ...
Optional: _SpecialForm = ...
Tuple: _SpecialForm = ...
Generic: _SpecialForm = ...
Protocol: _SpecialForm = ...
@@ -53,20 +55,17 @@ def no_type_check_decorator(decorator: _C) -> _C: ...
# Type aliases and type constructors
class TypeAlias:
class _Alias:
# Class for defining generic aliases for library types.
def __init__(self, target_type: type) -> None: ...
def __getitem__(self, typeargs: Any) -> Any: ...
Union = TypeAlias(object)
Optional = TypeAlias(object)
List = TypeAlias(object)
Dict = TypeAlias(object)
DefaultDict = TypeAlias(object)
Set = TypeAlias(object)
FrozenSet = TypeAlias(object)
Counter = TypeAlias(object)
Deque = TypeAlias(object)
List = _Alias()
Dict = _Alias()
DefaultDict = _Alias()
Set = _Alias()
FrozenSet = _Alias()
Counter = _Alias()
Deque = _Alias()
# Predefined type variables.
AnyStr = TypeVar('AnyStr', str, unicode)