)
self.assertIs(type(exc.__cause__), CustomError)
+ def test_deferred_evaluation_of_annotations(self):
+ class DeferredProto(Protocol):
+ x: DoesNotExist
+ self.assertEqual(get_protocol_members(DeferredProto), {"x"})
+ self.assertEqual(
+ annotationlib.get_annotations(DeferredProto, format=annotationlib.Format.STRING),
+ {'x': 'DoesNotExist'}
+ )
+
class GenericTests(BaseTestCase):
for base in cls.__mro__[:-1]: # without object
if base.__name__ in {'Protocol', 'Generic'}:
continue
- annotations = getattr(base, '__annotations__', {})
+ annotations = _lazy_annotationlib.get_annotations(
+ base, format=_lazy_annotationlib.Format.FORWARDREF
+ )
for attr in (*base.__dict__, *annotations):
if not attr.startswith('_abc_') and attr not in EXCLUDED_ATTRIBUTES:
attrs.add(attr)