MCPcopy Index your code
hub / github.com/RustPython/RustPython / _find_impl

Function _find_impl

Lib/functools.py:849–873  ·  view source on GitHub ↗

Returns the best matching implementation from *registry* for type *cls*. Where there is no registered implementation for a specific type, its method resolution order is used to find a more generic implementation. Note: if *registry* does not contain an implementation for the base *

(cls, registry)

Source from the content-addressed store, hash-verified

847 return _c3_mro(cls, abcs=mro)
848
849def _find_impl(cls, registry):
850 """Returns the best matching implementation from *registry* for type *cls*.
851
852 Where there is no registered implementation for a specific type, its method
853 resolution order is used to find a more generic implementation.
854
855 Note: if *registry* does not contain an implementation for the base
856 *object* type, this function may return None.
857
858 """
859 mro = _compose_mro(cls, registry.keys())
860 match = None
861 for t in mro:
862 if match is not None:
863 # If *match* is an implicit ABC but there is another unrelated,
864 # equally matching implicit ABC, refuse the temptation to guess.
865 if (t in registry and t not in cls.__mro__
866 and match not in cls.__mro__
867 and not issubclass(match, t)):
868 raise RuntimeError("Ambiguous dispatch: {} or {}".format(
869 match, t))
870 break
871 if t in registry:
872 match = t
873 return registry.get(match)
874
875def singledispatch(func):
876 """Single-dispatch generic function decorator.

Callers 1

dispatchFunction · 0.85

Calls 5

_compose_mroFunction · 0.85
issubclassFunction · 0.85
keysMethod · 0.45
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected