betty.attrs.common module

Settable attributes.

class betty.attrs.common.CommonAttr

Bases: Attr, Generic

An object attribute that supports common configuration operations.

This is a helper mix-in that provides shorthand access to common features to improve Developer Experience (DX).

abstractmethod default(default: Callable[[], SetT] | Callable[[OwnerT], SetT], /) CommonAttr[OwnerT, GetT, SetT]

Create a new attribute that proxies this one, and sets a default value.

abstract property optional: CommonAttr[OwnerT, GetT | None, SetT | None]

Return a new attribute like this one, but that also allows None.

abstractmethod setter(setter: Callable[[SetterSetT], SetT] | Callable[[OwnerT, SetterSetT], SetT], /) CommonAttr[OwnerT, GetT, SetterSetT]

Return a new attribute like this one, but with the given setter.