]> granicus.if.org Git - python/commitdiff
bpo-34921: Allow escaped NoReturn in get_type_hints (GH-9750)
authorNoah Wood <26890744+JohnnyHobo@users.noreply.github.com>
Mon, 8 Oct 2018 18:50:16 +0000 (14:50 -0400)
committerIvan Levkivskyi <levkivskyi@gmail.com>
Mon, 8 Oct 2018 18:50:16 +0000 (20:50 +0200)
Lib/typing.py

index 445a42492b6bcbf334102d231f1c83b8a4ff49c8..cfcbb3b7632842598859adb0836060e0f2b6435f 100644 (file)
@@ -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)):