Skip to content

Commit 6bc698b

Browse files
committed
Normalize None to a type, strip annotations
1 parent e1cde59 commit 6bc698b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/functools.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,14 @@ def _get_dispatch_annotation(func, param):
912912
ref_or_typeform = annotationlib.ForwardRef(ref_or_typeform, owner=func)
913913
if isinstance(ref_or_typeform, annotationlib.ForwardRef):
914914
try:
915-
return ref_or_typeform.evaluate(owner=func)
915+
ref_or_typeform = ref_or_typeform.evaluate(owner=func)
916916
except Exception:
917917
pass # Forward reference is unresolved.
918+
if ref_or_typeform is None:
919+
ref_or_typeform = type(None)
920+
if not isinstance(ref_or_typeform, annotationlib.ForwardRef):
921+
import typing
922+
ref_or_typeform = typing._strip_annotations(ref_or_typeform)
918923
return ref_or_typeform
919924

920925
def _get_dispatch_param_and_annotation(func, *, skip_first=False):

0 commit comments

Comments
 (0)