@@ -4223,46 +4223,51 @@ def evaluate_forward_ref(
42234223
42244224
42254225# Aliases for items that are in typing in all supported versions.
4226- # Explicitly assign these (rather than using `from typing import *` at the top),
4227- # so that we get a CI error if one of these is deleted from typing.py
4228- # in a future version of Python
4229- AbstractSet = typing .AbstractSet
4230- Annotated = typing .Annotated
4231- AnyStr = typing .AnyStr
4232- BinaryIO = typing .BinaryIO
4233- Callable = typing .Callable
4234- Collection = typing .Collection
4235- Container = typing .Container
4236- Dict = typing .Dict
4237- ForwardRef = typing .ForwardRef
4238- FrozenSet = typing .FrozenSet
4239- Generic = typing .Generic
4240- Hashable = typing .Hashable
4241- IO = typing .IO
4242- ItemsView = typing .ItemsView
4243- Iterable = typing .Iterable
4244- Iterator = typing .Iterator
4245- KeysView = typing .KeysView
4246- List = typing .List
4247- Mapping = typing .Mapping
4248- MappingView = typing .MappingView
4249- Match = typing .Match
4250- MutableMapping = typing .MutableMapping
4251- MutableSequence = typing .MutableSequence
4252- MutableSet = typing .MutableSet
4253- Optional = typing .Optional
4254- Pattern = typing .Pattern
4255- Reversible = typing .Reversible
4256- Sequence = typing .Sequence
4257- Set = typing .Set
4258- Sized = typing .Sized
4259- TextIO = typing .TextIO
4260- Tuple = typing .Tuple
4261- Union = typing .Union
4262- ValuesView = typing .ValuesView
4263- cast = typing .cast
4264- no_type_check = typing .no_type_check
4265- no_type_check_decorator = typing .no_type_check_decorator
4266- # This is private, but it was defined by typing_extensions for a long time
4267- # and some users rely on it.
4268- _AnnotatedAlias = typing ._AnnotatedAlias
4226+ # We use hasattr() checks so this library will continue to import on
4227+ # future versions of Python that may remove these names.
4228+ _typing_names = [
4229+ "AbstractSet" ,
4230+ "Annotated" ,
4231+ "AnyStr" ,
4232+ "BinaryIO" ,
4233+ "Callable" ,
4234+ "Collection" ,
4235+ "Container" ,
4236+ "Dict" ,
4237+ "ForwardRef" ,
4238+ "FrozenSet" ,
4239+ "Generic" ,
4240+ "Hashable" ,
4241+ "IO" ,
4242+ "ItemsView" ,
4243+ "Iterable" ,
4244+ "Iterator" ,
4245+ "KeysView" ,
4246+ "List" ,
4247+ "Mapping" ,
4248+ "MappingView" ,
4249+ "Match" ,
4250+ "MutableMapping" ,
4251+ "MutableSequence" ,
4252+ "MutableSet" ,
4253+ "Optional" ,
4254+ "Pattern" ,
4255+ "Reversible" ,
4256+ "Sequence" ,
4257+ "Set" ,
4258+ "Sized" ,
4259+ "TextIO" ,
4260+ "Tuple" ,
4261+ "Union" ,
4262+ "ValuesView" ,
4263+ "cast" ,
4264+ "no_type_check" ,
4265+ "no_type_check_decorator" ,
4266+ # This is private, but it was defined by typing_extensions for a long time
4267+ # and some users rely on it.
4268+ "_AnnotatedAlias" ,
4269+ ]
4270+ for _name in _typing_names :
4271+ if hasattr (typing , _name ):
4272+ globals ()[_name ] = getattr (typing , _name )
4273+ del _typing_names
0 commit comments