jangada.serialization.SerializableProperty.__get__#

SerializableProperty.__get__(instance: object | None, owner: type) T | Self#

Get the property value from an instance.

This method implements the descriptor get protocol. When accessed from the class, it returns the descriptor itself (for introspection). When accessed from an instance, it returns the stored value, initializing it with the default if this is the first access.

Parameters:
instanceobject | None

The instance from which the property is accessed, or None if accessed from the class.

ownertype

The class that owns this descriptor.

Returns:
T | Self

If accessed from an instance, returns the property value (type T). If accessed from the class, returns the descriptor itself (Self).

Notes

On first access from an instance, this method: 1. Calls __set__(instance, None) to initialize with default 2. Returns the initialized value 3. This triggers observers and post-initializer on first access

Examples

>>> class MyClass:
...     prop = SerializableProperty(default=42)
...
>>> MyClass.prop  # Access from class
<SerializableProperty object at 0x...>
>>> obj = MyClass()
>>> obj.prop  # Access from instance
42