diff options
author | Guido van Rossum <guido@python.org> | 2016-10-21 17:30:30 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-10-21 17:30:30 -0700 |
commit | 7e0062fca85237e785ce41a638f682495beb7540 (patch) | |
tree | b6334d050058982c171abf4f52775487fea585b6 | |
parent | e238ab5c813903fd7ce34929fc984fd0f0627ea8 (diff) | |
parent | 3b557991d4a7626cf12baf2277bc87acbc439744 (diff) | |
download | cpython-git-7e0062fca85237e785ce41a638f682495beb7540.tar.gz |
Two minor typing.py fixes (upstream #305) (3.5->3.6)
-rw-r--r-- | Lib/test/test_typing.py | 2 | ||||
-rw-r--r-- | 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 index fdbddb77c8..0d8532ebb7 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1182,7 +1182,7 @@ gth = get_type_hints 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 index 5761693401..261da5d5e2 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -894,7 +894,7 @@ def _replace_arg(arg, tvars, args): 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 @@ if sys.version_info[:2] >= (3, 3): 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) |