106106# legitimate imports of those modules.
107107
108108
109- def _type_check (arg , msg , is_argument = False ):
109+ def _type_check (arg , msg , is_argument = True ):
110110 """Check that the argument is a type, and return it (internal helper).
111111
112112 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):
119119 We append the repr() of the actual value (truncated to 100 chars).
120120 """
121121 invalid_generic_forms = (Generic , _Protocol )
122- if not is_argument :
122+ if is_argument :
123123 invalid_generic_forms = invalid_generic_forms + (ClassVar , )
124124
125125 if arg is None :
@@ -445,7 +445,7 @@ class ForwardRef(_Final, _root=True):
445445 '__forward_evaluated__' , '__forward_value__' ,
446446 '__forward_is_argument__' )
447447
448- def __init__ (self , arg , is_argument = False ):
448+ def __init__ (self , arg , is_argument = True ):
449449 if not isinstance (arg , str ):
450450 raise TypeError (f"Forward reference must be a string -- got { arg !r} " )
451451 try :
@@ -979,7 +979,7 @@ def get_type_hints(obj, globalns=None, localns=None):
979979 if value is None :
980980 value = type (None )
981981 if isinstance (value , str ):
982- value = ForwardRef (value , is_argument = True )
982+ value = ForwardRef (value , is_argument = False )
983983 value = _eval_type (value , base_globals , localns )
984984 hints [name ] = value
985985 return hints
0 commit comments