Skip to content

Commit b691969

Browse files
committed
More comments
1 parent fbc205e commit b691969

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/functools.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ def _get_singledispatch_annotated_param(func, *, _inside_dispatchmethod=False):
903903
idx = 1
904904
func = func.__func__
905905
# If it is a regular function:
906-
# Pick the first parameter if registering from singledispatch.
907-
# Pick the second parameter if registering from singledispatchmethod.
906+
# Pick the first parameter if registering via singledispatch.
907+
# Pick the second parameter if registering via singledispatchmethod.
908908
else:
909909
idx = _inside_dispatchmethod
910910

@@ -917,11 +917,14 @@ def _get_singledispatch_annotated_param(func, *, _inside_dispatchmethod=False):
917917
except IndexError:
918918
pass
919919

920-
# Otherwise delegate wrapped or ambiguous callables to inspect.signature (slower).
920+
# Fall back to inspect.signature (slower, but complete).
921921
import inspect
922922
try:
923923
param = list(inspect.signature(func).parameters.values())[idx]
924-
if param.kind < 3: # False for (*, arg) and (**args) parameters.
924+
# True for positional "(arg)" and positional-only "(arg, /)" parameters.
925+
# True for variadic positional "(*args)" parameters for backward compatibility.
926+
# False for keyword-only "(*, arg)" and keyword variadic "(**args)" parameters.
927+
if param.kind < 3:
925928
return param.name
926929
except IndexError:
927930
pass

0 commit comments

Comments
 (0)