{ } Raw JSON

bundles / traitlets 5.16.2 / traitlets / config / configurable / SingletonScope / add

function

traitlets.config.configurable:SingletonScope.add

source: /traitlets/config/configurable.py:595

Signature

def add(self, inst: SingletonConfigurable) → None

Summary

Pre-seed the registry with an instance you built yourself, so that .instance() returns that object inside the scope.

Extended Summary

Writes through to the singleton parents of type(inst), the same way the classic global path does, so a subclass instance is also returned when resolving via an ancestor class. This is the only way to control which object in-scope .instance() calls receive, since they otherwise construct a fresh one.

Aliases

  • traitlets.config.SingletonScope.add

Referenced by

This package