API Reference
Alternative implementation of dataclasses.
- @udataclasses.dataclass(cls: type[T] | None = None, **kwargs: Any) type[T] | Callable[[type[T]], type[T]][source]
Decorator to transform a normal class into a dataclass.
Refer to the documentation for
dataclasses.dataclass().
- udataclasses.asdict(obj: object, *, dict_factory: ~typing.Any = <class 'dict'>) Any[source]
Convert dataclass instance to a dict.
Refer to the documentation for
dataclasses.asdict()
- udataclasses.astuple(obj: object, *, tuple_factory: ~typing.Any = <class 'tuple'>) Any[source]
Intentionally unimplemented as we do not preserve field ordering.
Refer to the documentation for
dataclasses.astuple()
- udataclasses.field(*, default: Any | Literal[MissingType.MISSING] = MissingType.MISSING, default_factory: Callable[[], Any] | Literal[MissingType.MISSING] = MissingType.MISSING, init: bool = True, repr: bool = True, hash: bool | None = None, compare: bool = True) Field[source]
Function for explicitly declaring a field.
Refer to the documentation for
dataclasses.field().
- udataclasses.fields(obj: object) tuple[Field, ...][source]
Retrieve all the Fields of an object or class.
Fields are returned in alphabetical order by name.
Refer to the documentation for
dataclasses.fields().
- udataclasses.is_dataclass(obj: object) bool[source]
Check if an object or class is a dataclass.
Refer to the documentation for
dataclasses.is_dataclass().
- udataclasses.make_dataclass(cls_name: str, fields: Iterable[str | tuple[str, Any] | tuple[str, Any, Any]], *, bases: tuple[type, ...] = (), namespace: dict[str, Any] | None = None, init: bool = True, repr: bool = True, eq: bool = True, order: bool = False, unsafe_hash: bool = False, frozen: bool = False) type[Any][source]
Dynamically create a dataclass.
Refer to the documentation for
dataclasses.make_dataclass().
- udataclasses.replace(obj: T, **changes: Any) T[source]
Create a new object with the specified fields replaced.
Refer to the documentation for
dataclasses.replace().
- exception udataclasses.FrozenInstanceError[source]
Exception raised when attempting to mutate a frozen dataclass instance.
Refer to the documentation for
dataclasses.FrozenInstanceError.
- class udataclasses.Field[source]
Internal representation of a field provided by introspection routines. Users should not directly instantiate this class.
- udataclasses.MISSING
Sentinel default value for fields without a default value.
Refer to the documentation for
dataclasses.MISSING.