106
106
# legitimate imports of those modules.
107
107
108
108
109
- def _type_check (arg , msg , is_argument = False ):
109
+ def _type_check (arg , msg , is_argument = True ):
110
110
"""Check that the argument is a type, and return it (internal helper).
111
111
112
112
As a special case, accept None and return type(None) instead. Also wrap strings
@@ -119,7 +119,7 @@ def _type_check(arg, msg, is_argument=False):
119
119
We append the repr() of the actual value (truncated to 100 chars).
120
120
"""
121
121
invalid_generic_forms = (Generic , _Protocol )
122
- if not is_argument :
122
+ if is_argument :
123
123
invalid_generic_forms = invalid_generic_forms + (ClassVar , )
124
124
125
125
if arg is None :
@@ -445,7 +445,7 @@ class ForwardRef(_Final, _root=True):
445
445
'__forward_evaluated__' , '__forward_value__' ,
446
446
'__forward_is_argument__' )
447
447
448
- def __init__ (self , arg , is_argument = False ):
448
+ def __init__ (self , arg , is_argument = True ):
449
449
if not isinstance (arg , str ):
450
450
raise TypeError (f"Forward reference must be a string -- got { arg !r} " )
451
451
try :
@@ -979,7 +979,7 @@ def get_type_hints(obj, globalns=None, localns=None):
979
979
if value is None :
980
980
value = type (None )
981
981
if isinstance (value , str ):
982
- value = ForwardRef (value , is_argument = True )
982
+ value = ForwardRef (value , is_argument = False )
983
983
value = _eval_type (value , base_globals , localns )
984
984
hints [name ] = value
985
985
return hints
0 commit comments