From 5eea0ad50c32d38909ff4e29309e2cc3c6ccb2c0 Mon Sep 17 00:00:00 2001 From: Noah Wood <26890744+JohnnyHobo@users.noreply.github.com> Date: Mon, 8 Oct 2018 14:50:16 -0400 Subject: [PATCH] bpo-34921: Allow escaped NoReturn in get_type_hints (GH-9750) --- Lib/typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/typing.py b/Lib/typing.py index 445a42492b..cfcbb3b763 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -130,7 +130,7 @@ def _type_check(arg, msg, is_argument=True): if (isinstance(arg, _GenericAlias) and arg.__origin__ in invalid_generic_forms): raise TypeError(f"{arg} is not valid as type argument") - if (isinstance(arg, _SpecialForm) and arg is not Any or + if (isinstance(arg, _SpecialForm) and arg not in (Any, NoReturn) or arg in (Generic, _Protocol)): raise TypeError(f"Plain {arg} is not valid as type argument") if isinstance(arg, (type, TypeVar, ForwardRef)): -- 2.49.0