Skip to content

Commit 7968570

Browse files
committed
Remove the get_annotations dance for now
1 parent f6c102f commit 7968570

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

Lib/functools.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,8 @@ def _get_dispatch_param_name(func, *, skip_first_param=False):
898898
return next(iter(params[skip_first_param:pos_param_count]), None)
899899

900900
def _get_dispatch_annotation(func, param):
901-
import annotationlib
902-
annotations = annotationlib.get_annotations(func, format=annotationlib.Format.FORWARDREF)
901+
import annotationlib, typing
902+
annotations = typing.get_type_hints(func, format=annotationlib.Format.FORWARDREF)
903903
try:
904904
fwdref_or_typeform = annotations[param]
905905
except KeyError:
@@ -908,18 +908,6 @@ def _get_dispatch_annotation(func, param):
908908
f"Add missing annotation to parameter {param!r} of {func.__qualname__!r} "
909909
f"or use `@register(some_class)`."
910910
) from None
911-
if isinstance(fwdref_or_typeform, str):
912-
fwdref_or_typeform = annotationlib.ForwardRef(fwdref_or_typeform, owner=func)
913-
if isinstance(fwdref_or_typeform, annotationlib.ForwardRef):
914-
try:
915-
fwdref_or_typeform = fwdref_or_typeform.evaluate(owner=func)
916-
except Exception:
917-
pass # Forward reference is unresolved.
918-
if fwdref_or_typeform is None:
919-
fwdref_or_typeform = type(None)
920-
if not isinstance(fwdref_or_typeform, annotationlib.ForwardRef):
921-
import typing
922-
fwdref_or_typeform = typing._strip_annotations(fwdref_or_typeform)
923911
return fwdref_or_typeform
924912

925913
def _get_dispatch_param_and_annotation(func, *, skip_first_param=False):

0 commit comments

Comments
 (0)