Skip to content

supporting named arguments #28

@cunningjames

Description

@cunningjames

Right now this results in a dispatch error, because dispatch is based only on unnamed arguments:

@multimethod
def f(foo: str):
    return foo

f(foo="bar")
# => DispatchError: ('f: 0 methods found', (), [])

Not a huge deal, but some people are rather particular about using named arguments whenever possible. Would this be possible to support?

This would complicate the dispatch algorithm, admittedly. You'd have to keep track of argument names for each overload and, accordingly, rearrange *args / **kwargs in multimethod.__call__(). This could get a bit gross when accounting for argument names that are repeated or arranged in different orders for different overloads ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions