[Python-checkins] cpython (3.5): Two minor typing.py fixes (upstream #305)
guido.van.rossum
python-checkins at python.org
Fri Oct 21 20:34:47 EDT 2016
https://hg.python.org/cpython/rev/991fd1fec730
changeset: 104636:991fd1fec730
branch: 3.5
parent: 104633:c3363f684a2d
user: Guido van Rossum <guido at python.org>
date: Fri Oct 21 17:30:29 2016 -0700
summary:
Two minor typing.py fixes (upstream #305)
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