Skip to content

Commit 316741e

Browse files
feat: compute annotations only if necessary
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 19d925a commit 316741e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/typing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,11 +2020,12 @@ def _proto_hook(cls, other):
20202020
break
20212021

20222022
# ...or in annotations, if it is a sub-protocol.
2023-
annotations = _lazy_annotationlib.get_annotations(base, format=_lazy_annotationlib.Format.FORWARDREF)
20242023
if (
20252024
issubclass(other, Generic)
20262025
and getattr(other, "_is_protocol", False)
2027-
and attr in annotations
2026+
and attr in _lazy_annotationlib.get_annotations(
2027+
base, format=_lazy_annotationlib.Format.FORWARDREF
2028+
)
20282029
):
20292030
break
20302031
else:

0 commit comments

Comments
 (0)