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), {})
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)
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)