quchip.utils.registry¶
Subclass registration and serialization dispatch.
The declaration class BaseThing(Registrable, registry_root=True) makes a
registry for that family. Concrete subclasses register under their qualified
names. The registry excludes registry roots and abstract classes.
to_dict supplies the type tag. A registry root’s from_dict finds
the concrete class and passes it the payload and all extra arguments. Concrete
classes implement from_dict or _from_dict_payload. The default payload
constructor is cls().
Classes
Mixin that owns a subclass registry and the shared (de)serialization contract. |
- class quchip.utils.registry.Registrable[source]¶
Bases:
objectMixin that owns a subclass registry and the shared (de)serialization contract.
- classmethod from_dict(data, *args, **kwargs)[source]¶
Reconstruct the object from the output of
to_dict().On the registry root, dispatch to the concrete subclass that
data["type"]names, and send*args/**kwargsto it. On a concrete subclass, use_from_dict_payload(). Concrete subclasses that carry a payload override this method directly.