API Reference

Supercharge your CircuitPython classes similar to CPython dataclasses.

  • Author(s): Alec Delaney

Implementation Notes

Hardware:

None

Software and Dependencies:

class circuitpython_nitroclass.Field(default_factory, init, repr, hash, compare, priority, type, coerce, validation)

Create new instance of Field(default_factory, init, repr, hash, compare, priority, type, coerce, validation)

coerce

Alias for field number 7

compare

Alias for field number 4

default_factory

Alias for field number 0

hash

Alias for field number 3

init

Alias for field number 1

priority

Alias for field number 5

repr

Alias for field number 2

type

Alias for field number 6

validation

Alias for field number 8

exception circuitpython_nitroclass.FrozenInstanceError

Exception raised when attempting to modify frozen instances.

exception circuitpython_nitroclass.ValidationError

Exception raised when failing to validate or coerce a field.

circuitpython_nitroclass.field(*, default: Any = MISSING, default_factory: Callable[[], Any] | _MissingSentinel = MISSING, init: bool = True, repr: bool = True, hash: bool | None = None, compare: bool = True, priority: int = 0, type: Type | _MissingSentinel = MISSING, coerce: bool = False, validation: Callable[[Self, Any], bool] | None = None) Field

Implement a field for a nitro class.

circuitpython_nitroclass.nitroclass(cls: C | None = None, *, init: bool = True, repr: bool = True, eq: bool = True, order: bool = False, unsafe_hash: bool = False, frozen: bool = False) C

Turn the decorated class into a nitro class.