TREESCOPE_HANDLER_REGISTRY

TREESCOPE_HANDLER_REGISTRY#

treescope.type_registries.TREESCOPE_HANDLER_REGISTRY: dict[type[Any], renderers.TreescopeNodeHandler]#

Global registry of custom treescope handlers, keyed by type.

If a type is not present in this registry, the entries of that type’s __mro__ will also be searched. Additionally, virtual base classes will be checked if the abtract base class is in VIRTUAL_BASE_CLASSES.

The handler itself will be passed the object, and can either return a treescope rendering or the NotImplemented sentinel, just like an ordinary treescope handler.

This registry is primarily intended to add treescope support to custom types without requiring the type to be modified. If you can modify the type, you can instead define the __treescope_repr__ method on the type itself; this has precedence over the registry.