mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-46643: Fix stringized P.args/P.kwargs with get_type_hints (GH-31238)
(cherry picked from commit 75d2d945b4
)
Co-authored-by: Gregory Beauregard <greg@greg.red>
This commit is contained in:
parent
60b561c246
commit
257f5be7f7
3 changed files with 15 additions and 1 deletions
|
@ -169,7 +169,8 @@ def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms=
|
|||
return arg
|
||||
if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
|
||||
raise TypeError(f"Plain {arg} is not valid as type argument")
|
||||
if isinstance(arg, (type, TypeVar, ForwardRef, types.UnionType, ParamSpec)):
|
||||
if isinstance(arg, (type, TypeVar, ForwardRef, types.UnionType, ParamSpec,
|
||||
ParamSpecArgs, ParamSpecKwargs)):
|
||||
return arg
|
||||
if not callable(arg):
|
||||
raise TypeError(f"{msg} Got {arg!r:.100}.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue