summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 3678962..245592b 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -2020,10 +2020,13 @@ def _proto_hook(cls, other):
break
# ...or in annotations, if it is a sub-protocol.
- annotations = getattr(base, '__annotations__', {})
- if (isinstance(annotations, collections.abc.Mapping) and
- attr in annotations and
- issubclass(other, Generic) and getattr(other, '_is_protocol', False)):
+ if (
+ issubclass(other, Generic)
+ and getattr(other, "_is_protocol", False)
+ and attr in _lazy_annotationlib.get_annotations(
+ base, format=_lazy_annotationlib.Format.FORWARDREF
+ )
+ ):
break
else:
return NotImplemented