zensols.dataclasses namespace

Submodules

zensols.dataclasses.inspect module

Very simple object relational mapping.

class zensols.dataclasses.inspect.ClassField(name, dtype, doc, kwargs, data_field)[source]

Bases: ClassMember

Metadata describing a dataclass field.

__init__(name, dtype, doc, kwargs, data_field)
data_field: Field

The field data from the dataclass.

class zensols.dataclasses.inspect.ClassMember(name, dtype, doc, kwargs)[source]

Bases: ClassField, Dictable

Metadata that represents a member (dataclass field or property).

__init__(name, dtype, doc, kwargs)
class zensols.dataclasses.inspect.ClassProperty(name, dtype, doc, kwargs, prop)[source]

Bases: ClassMember

Metadata describing a class property.

__init__(name, dtype, doc, kwargs, prop)
prop: property

The class property from the dataclass.

class zensols.dataclasses.inspect.DataclassMetadata(class_type)[source]

Bases: Dictable

Introspects a dataclass and exposes metadata about its members.

This class provides a unified metadata view of the fields and properties defined by class_type. Dataclass fields are represented by ClassField instances and Python properties by ClassProperty instances. Each member records its name, declared type, and documentation when available.

Field documentation is obtained from string literals immediately following field declarations in the class body. Property documentation is obtained from the property’s getter docstring, and its type is inferred from the getter’s return annotation.

The instance also provides a read-only mapping-like interface from member names to ClassMember metadata. Iteration yields dataclass fields followed by properties.

__init__(class_type)
class_type: type

the dataclass type to introspect.

property doc: ClassDoc

The docstring of the class.

property fields: dict[str, ClassField]

The fields of class_type.

property fields_by_order: tuple[ClassField, ...]

Create field metadata for class_type.

get(name, default=None)[source]
Return type:

ClassMember | None

items()[source]
Return type:

ItemsView[str, ClassMember]

keys()[source]
Return type:

KeysView[str]

property properties: dict[str, ClassProperty]

The properties of class_type.

property properties_by_order: tuple[ClassProperty, ...]

Property metadata for class_type.

values()[source]
Return type:

ValuesView[ClassMember]