MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _find_impl

Function _find_impl

tools/python-3.11.9-amd64/Lib/functools.py:774–798  ·  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

772 return _c3_mro(cls, abcs=mro)
773
774def _find_impl(cls, registry):
775 """Returns the best matching implementation from *registry* for type *cls*.
776
777 Where there is no registered implementation for a specific type, its method
778 resolution order is used to find a more generic implementation.
779
780 Note: if *registry* does not contain an implementation for the base
781 *object* type, this function may return None.
782
783 """
784 mro = _compose_mro(cls, registry.keys())
785 match = None
786 for t in mro:
787 if match is not None:
788 # If *match* is an implicit ABC but there is another unrelated,
789 # equally matching implicit ABC, refuse the temptation to guess.
790 if (t in registry and t not in cls.__mro__
791 and match not in cls.__mro__
792 and not issubclass(match, t)):
793 raise RuntimeError("Ambiguous dispatch: {} or {}".format(
794 match, t))
795 break
796 if t in registry:
797 match = t
798 return registry.get(match)
799
800def singledispatch(func):
801 """Single-dispatch generic function decorator.

Callers 1

dispatchFunction · 0.85

Calls 4

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

Tested by

no test coverage detected