mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Two minor typing.py fixes (upstream #305) (3.6->3.7)
This commit is contained in:
commit
e86c1d1091
2 changed files with 2 additions and 6 deletions
|
@ -1182,7 +1182,7 @@ gth = get_type_hints
|
||||||
class GetTypeHintTests(BaseTestCase):
|
class GetTypeHintTests(BaseTestCase):
|
||||||
@skipUnless(PY36, 'Python 3.6 required')
|
@skipUnless(PY36, 'Python 3.6 required')
|
||||||
def test_get_type_hints_modules(self):
|
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_module2), {})
|
||||||
self.assertEqual(gth(ann_module3), {})
|
self.assertEqual(gth(ann_module3), {})
|
||||||
|
|
||||||
|
|
|
@ -894,7 +894,7 @@ def _replace_arg(arg, tvars, args):
|
||||||
return arg._subs_repr(tvars, args)
|
return arg._subs_repr(tvars, args)
|
||||||
if isinstance(arg, TypeVar):
|
if isinstance(arg, TypeVar):
|
||||||
for i, tvar in enumerate(tvars):
|
for i, tvar in enumerate(tvars):
|
||||||
if arg.__name__ == tvar.__name__:
|
if arg == tvar:
|
||||||
return args[i]
|
return args[i]
|
||||||
return _type_repr(arg)
|
return _type_repr(arg)
|
||||||
|
|
||||||
|
@ -1322,10 +1322,6 @@ if sys.version_info[:2] >= (3, 3):
|
||||||
hints = obj.__annotations__
|
hints = obj.__annotations__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return {}
|
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():
|
for name, value in hints.items():
|
||||||
if value is None:
|
if value is None:
|
||||||
value = type(None)
|
value = type(None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue