bpo-46643: Fix stringized P.args/P.kwargs with get_type_hints (GH-31238) · python/cpython@75d2d94

Original file line numberDiff line numberDiff line change

@@ -181,7 +181,8 @@ def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms=

181181

return arg

182182

if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):

183183

raise TypeError(f"Plain {arg} is not valid as type argument")

184-

if isinstance(arg, (type, TypeVar, ForwardRef, types.UnionType, ParamSpec)):

184+

if isinstance(arg, (type, TypeVar, ForwardRef, types.UnionType, ParamSpec,

185+

ParamSpecArgs, ParamSpecKwargs)):

185186

return arg

186187

if not callable(arg):

187188

raise TypeError(f"{msg} Got {arg!r:.100}.")