jangada.serialization.SerializableMetatype#

class jangada.serialization.SerializableMetatype(name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any)#

Bases: ABCMeta

Metaclass for automatic registration and introspection of Serializable classes.

This metaclass provides automatic registration of all Serializable subclasses, discovery of SerializableProperty descriptors, and management of type registries for serialization support.

See also

Serializable

The base class using this metaclass

SerializableProperty

Property descriptor for serializable attributes

Notes

This metaclass extends ABCMeta to allow Serializable classes to also be abstract base classes if needed.

The metaclass automatically: 1. Registers each subclass in the global registry 2. Walks the MRO to collect all SerializableProperty descriptors 3. Creates the _serializable_properties dict on each subclass

Examples

Creating a Serializable class automatically registers it:

>>> class MyClass(Serializable):
...     value = SerializableProperty(default=0)
...
>>> get_full_qualified_name(MyClass) in Serializable
True

Access classes by qualified name:

>>> qualname = get_full_qualified_name(MyClass)
>>> retrieved = Serializable[qualname]
>>> retrieved is MyClass
True

Property discovery happens automatically:

>>> 'value' in MyClass._serializable_properties
True

Register custom primitive types:

>>> class CustomType:
...     pass
>>> Serializable.register_primitive_type(CustomType)
>>> Serializable.is_primitive_type(CustomType)
True