Cobble is a Python library designed for the easy creation of data objects. It automatically implements common methods such as `__eq__` and `__repr__`, simplifying the boilerplate typically associated with simple data-holding classes. The current version is 0.1.4, released on June 1, 2024, and it is actively maintained with a stable release cadence.
pip install cobbleVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a simple data object `Song` using the `@cobble.data` decorator and `cobble.field()`. It also shows how to create a more complex structure like an expression tree with `Literal` and `Add` and then process it using a visitor pattern with `cobble.visitor`.
Use `default_factory` for mutable defaults, e.g., `my_list = cobble.field(default_factory=list)`.
Prefer using `__post_init__` for custom initialization logic or ensure your custom `__init__` explicitly initializes all fields defined by `cobble.field()`.
Always instantiate the class (e.g., `instance = MyClass(...)`) before attempting to access instance-specific fields. Use `typing.ClassVar` if an attribute truly needs to be a class-level variable and should not be part of the `__init__` generated by `cobble`.
No dependency data recorded yet.