easyfabric.data.dataclass_utils
json
re
asdict
fields
Enum
Any
Union
get_args
get_origin
get_type_hints
uuid4
get_override
to_snake_case
def to_snake_case(string: str) -> str
DataClassFromDictMixin Objects
class DataClassFromDictMixin()
Enhanced mixin: Converts dataclasses to/from dictionaries with recursive support for nested dataclasses/lists. Supports flexible YAML keys (any casing → lowercase snake_case) and unwraps Optional/Union types.
dict
def dict()
Convert the dataclass instance to a dictionary
from_dict
@classmethod
def from_dict(cls, data: Union[dict, str])
Create a dataclass instance from a dictionary or JSON string.
Arguments:
data- A dictionary or JSON string to convert to a dataclass instance.
Returns:
An instance of the dataclass.
Raises:
ValueError- If the input string is not valid JSON.TypeError- If the input is not a dictionary or JSON string.
__post_init__
def __post_init__()
Auto-apply overrides from global dict for None fields, with fallbacks.