bpo-46644: Remove callable() requirement from typing._type_check (GH-31151)

We also remove all the tests that check for integer literals.
This commit is contained in:
Gregory Beauregard 2022-03-11 17:12:17 -08:00 committed by GitHub
parent a89c29fbcc
commit 870b22b9c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 33 deletions

View file

@ -185,10 +185,7 @@ 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,
ParamSpecArgs, ParamSpecKwargs, TypeVarTuple)):
return arg
if not callable(arg):
if type(arg) is tuple:
raise TypeError(f"{msg} Got {arg!r:.100}.")
return arg