Reference

class multimethod.DispatchError[source]

Bases: TypeError

multimethod

class multimethod.multimethod(func)[source]

Bases: dict

A callable directed acyclic graph of methods.

__call__(*args, **kwargs)[source]

Resolve and dispatch to best method.

__delitem__(types: tuple)[source]

Delete self[key].

__init__(func: Callable)[source]

Initialize self. See help(type(self)) for accurate signature.

__missing__(types: tuple) → Callable[source]

Find and cache the next applicable method of given types.

static __new__(cls, func)[source]

Create and return a new object. See help(type) for accurate signature.

__setitem__(types: tuple, func: Callable)[source]

Set self[key] to value.

clean()[source]

Empty the cache.

property docstring

a descriptive docstring of all registered functions

evaluate()[source]

Evaluate any pending forward references.

This can be called explicitly when using forward references, otherwise cache misses will evaluate.

parents(types: tuple) → set[source]

Find immediate parents of potential key.

register(*args)[source]

Decorator for registering a function.

Optionally call with types to return a decorator for unannotated functions.

class multimethod.multidispatch(func)[source]

Bases: multimethod.multimethod

Provisional wrapper for future compatibility with functools.singledispatch.

overload

class multimethod.overload(func)[source]

Bases: collections.OrderedDict

Ordered functions which dispatch based on their annotated predicates.

__call__(*args, **kwargs)[source]

Dispatch to first matching function.

__init__(func: Callable)[source]

Initialize self. See help(type(self)) for accurate signature.

static __new__(cls, func)[source]

Create and return a new object. See help(type) for accurate signature.

register(func: Callable) → Callable[source]

Decorator for registering a function.

multimethod.isa(*types) → Callable[source]

Partially bound isinstance.