195
195
196
196
197
197
# Used on `TypeVar` objects with no default:
198
- NoDefault = getattr (typing_extensions , "NoDefault" , object ())
198
+ NoDefaults = (
199
+ getattr (typing , "NoDefault" , object ()),
200
+ getattr (typing_extensions , "NoDefault" , object ()),
201
+ )
199
202
200
203
# We use this variable to be sure that we are working with a type from `typing`:
201
204
typing_root_type = (typing ._Final , typing ._GenericAlias ) # type: ignore
@@ -443,7 +446,7 @@ def is_generic_type(type_):
443
446
)
444
447
445
448
446
- def _try_import_forward_ref (thing , typ , * , type_params = () ): # pragma: no cover
449
+ def _try_import_forward_ref (thing , typ , * , type_params ): # pragma: no cover
447
450
"""
448
451
Tries to import a real bound or default type from ``ForwardRef`` in ``TypeVar``.
449
452
@@ -1090,7 +1093,7 @@ def resolve_TypeVar(thing):
1090
1093
type_var_key = f"typevar={ thing !r} "
1091
1094
1092
1095
bound = getattr (thing , "__bound__" , None )
1093
- default = getattr (thing , "__default__" , NoDefault )
1096
+ default = getattr (thing , "__default__" , NoDefaults [ 0 ] )
1094
1097
original_strategies = []
1095
1098
1096
1099
def resolve_strategies (typ ):
@@ -1106,7 +1109,7 @@ def resolve_strategies(typ):
1106
1109
1107
1110
if bound is not None :
1108
1111
resolve_strategies (bound )
1109
- if default is not NoDefault : # pragma: no cover
1112
+ if default not in NoDefaults : # pragma: no cover
1110
1113
# Coverage requires 3.13 or `typing_extensions` package.
1111
1114
resolve_strategies (default )
1112
1115
0 commit comments