[Python-checkins] cpython (merge 3.6 -> default): Two minor typing.py fixes (upstream #305) (3.6->3.7)

guido.van.rossum python-checkins at python.org
Fri Oct 21 20:34:47 EDT 2016


https://hg.python.org/cpython/rev/862abf309b78
changeset:   104638:862abf309b78
parent:      104635:c5fb5ac84f1e
parent:      104637:02bc01e18b9c
user:        Guido van Rossum <guido at python.org>
date:        Fri Oct 21 17:30:31 2016 -0700
summary:
  Two minor typing.py fixes (upstream #305) (3.6->3.7)

files:
  Lib/test/test_typing.py |  2 +-
  Lib/typing.py           |  6 +-----
  2 files changed, 2 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -1182,7 +1182,7 @@
 class GetTypeHintTests(BaseTestCase):
     @skipUnless(PY36, 'Python 3.6 required')
     def test_get_type_hints_modules(self):
-        self.assertEqual(gth(ann_module), {'x': int, 'y': str})
+        self.assertEqual(gth(ann_module), {1: 2, 'f': Tuple[int, int], 'x': int, 'y': str})
         self.assertEqual(gth(ann_module2), {})
         self.assertEqual(gth(ann_module3), {})
 
diff --git a/Lib/typing.py b/Lib/typing.py
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -894,7 +894,7 @@
         return arg._subs_repr(tvars, args)
     if isinstance(arg, TypeVar):
         for i, tvar in enumerate(tvars):
-            if arg.__name__ == tvar.__name__:
+            if arg == tvar:
                 return args[i]
     return _type_repr(arg)
 
@@ -1322,10 +1322,6 @@
                 hints = obj.__annotations__
             except AttributeError:
                 return {}
-            # we keep only those annotations that can be accessed on module
-            members = obj.__dict__
-            hints = {name: value for name, value in hints.items()
-                                              if name in members}
             for name, value in hints.items():
                 if value is None:
                     value = type(None)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list