Skip to content
Prev Previous commit
Next Next commit
Collate all unconditionally re-exported names
  • Loading branch information
AA-Turner committed Jan 4, 2022
commit 5394de39ee70337ccbb0c5f2544c2f42ee000623
47 changes: 21 additions & 26 deletions typing_extensions/src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,28 @@
'TYPE_CHECKING',
]

# Unconditionally re-exported names from typing
ClassVar = typing.ClassVar
Type = typing.Type # This is not a real generic class. Don't use outside annotations.

NewType = typing.NewType
NoReturn = typing.NoReturn
overload = typing.overload
Text = typing.Text
TYPE_CHECKING = typing.TYPE_CHECKING

AsyncContextManager = typing.AsyncContextManager
AsyncGenerator = typing.AsyncGenerator
AsyncIterable = typing.AsyncIterable
AsyncIterator = typing.AsyncIterator
Awaitable = typing.Awaitable
ContextManager = typing.ContextManager
Coroutine = typing.Coroutine

ChainMap = typing.ChainMap
Counter = typing.Counter
Deque = typing.Deque
DefaultDict = typing.DefaultDict

# Some unconstrained type variables. These are used by the container types.
# (These are not for export.)
Expand All @@ -68,8 +89,6 @@ def __repr__(self):
return 'typing_extensions.' + self._name


ClassVar = typing.ClassVar

# On older versions of typing there is an internal class named "Final".
# 3.8+
if hasattr(typing, 'Final'):
Expand Down Expand Up @@ -152,37 +171,13 @@ def __getitem__(self, parameters):
checking verifying that the parameter is actually a value
instead of a type.""")

overload = typing.overload

# This is not a real generic class. Don't use outside annotations.
Type = typing.Type

# Various ABCs mimicking those in collections.abc.
# A few are simply re-exported for completeness.
Awaitable = typing.Awaitable
Coroutine = typing.Coroutine
AsyncIterable = typing.AsyncIterable
AsyncIterator = typing.AsyncIterator
Deque = typing.Deque
ContextManager = typing.ContextManager
AsyncContextManager = typing.AsyncContextManager
DefaultDict = typing.DefaultDict

# 3.7.2+
if hasattr(typing, 'OrderedDict'):
OrderedDict = typing.OrderedDict
# 3.7.0-3.7.2
else:
OrderedDict = typing._alias(collections.OrderedDict, (KT, VT))

Counter = typing.Counter
ChainMap = typing.ChainMap
AsyncGenerator = typing.AsyncGenerator

NewType = typing.NewType
Text = typing.Text
TYPE_CHECKING = typing.TYPE_CHECKING

_PROTO_WHITELIST = ['Callable', 'Awaitable',
'Iterable', 'Iterator', 'AsyncIterable', 'AsyncIterator',
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible',
Expand Down