mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user