[Python-checkins] bpo-34921: Allow escaped NoReturn in get_type_hints (GH-9750)

Ivan Levkivskyi webhook-mailer at python.org
Mon Oct 8 14:50:21 EDT 2018


https://github.com/python/cpython/commit/5eea0ad50c32d38909ff4e29309e2cc3c6ccb2c0
commit: 5eea0ad50c32d38909ff4e29309e2cc3c6ccb2c0
branch: master
author: Noah Wood <26890744+JohnnyHobo at users.noreply.github.com>
committer: Ivan Levkivskyi <levkivskyi at gmail.com>
date: 2018-10-08T20:50:16+02:00
summary:

bpo-34921: Allow escaped NoReturn in get_type_hints (GH-9750)

files:
M Lib/typing.py

diff --git a/Lib/typing.py b/Lib/typing.py
index 445a42492b6b..cfcbb3b76328 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)):



More information about the Python-checkins mailing list