Skip to content

Commit b670957

Browse files
committed
naming: _find_matching_multimethod -> _resolve_multimethod
1 parent 4b204a4 commit b670957

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

unpythonic/dispatch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ def _format_method(method): # Taking a page from Julia and some artistic libert
472472
source, firstlineno = inspect.getsourcelines(function)
473473
return f"{thecallable.__qualname__}{str(thesignature)} from {filename}:{firstlineno}"
474474

475-
def _find_matching_multimethod(dispatcher, args, kwargs):
475+
# Find the first matching multimethod that is registered on `dispatcher`.
476+
def _resolve_multimethod(dispatcher, args, kwargs):
476477
multimethods = _list_multimethods(dispatcher, _extract_self_or_cls(dispatcher, args))
477478
for thecallable, type_signature in multimethods:
478479
try:
@@ -554,7 +555,7 @@ def _setup(fullname, multimethod):
554555
# Create the dispatcher. This will replace the original function.
555556
@wraps(multimethod)
556557
def dispatcher(*args, **kwargs):
557-
thecallable = _find_matching_multimethod(dispatcher, args, kwargs)
558+
thecallable = _resolve_multimethod(dispatcher, args, kwargs)
558559
if thecallable:
559560
return thecallable(*args, **kwargs)
560561
_raise_multiple_dispatch_error(dispatcher, args, kwargs,

unpythonic/fun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from .arity import arities, resolve_bindings, tuplify_bindings, UnknownArity
2323
from .fold import reducel
24-
from .dispatch import isgeneric, _find_matching_multimethod
24+
from .dispatch import isgeneric, _resolve_multimethod
2525
from .dynassign import dyn, make_dynvar
2626
from .regutil import register_decorator
2727
from .symbol import sym
@@ -223,7 +223,7 @@ def curried(*args, **kwargs):
223223
nargs = len(args)
224224
if (nargs < min_arity or
225225
(isgeneric(f) == "generic" and min_arity <= nargs <= max_arity and
226-
not _find_matching_multimethod(f, args, kwargs))):
226+
not _resolve_multimethod(f, args, kwargs))):
227227
p = partial(f, *args, **kwargs)
228228
if islazy(f):
229229
p = passthrough_lazy_args(p)

0 commit comments

Comments
 (0)