betty.attr module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.attr module

The Attr API.

class betty.attr.Attr

  Bases: `Generic`[`_InstanceT`, `_ValueT`], `ABC`

  A base class for an immutable property-like attribute.

  To test your own subclasses, use `betty.test_utils.attr.AttrTestBase`.

  __init__(attr_name: str)
  get_attr(instance: _InstanceT) → _ValueT

    Get the attribute value.

  abstract new_attr(instance: _InstanceT) → _ValueT

    Create a new attribute value.

class betty.attr.MutableAttr

  Bases: `Generic`[`_InstanceT`, `_ValueT`, `_SetT`], `Attr`[`_InstanceT`, `_ValueT`]

  A base class for a mutable property-like attribute.

  To test your own subclasses, use `betty.test_utils.attr.MutableAttrTestBase`.

  abstract del_attr(instance: _InstanceT) → None

    Delete the attribute value.

  abstract set_attr(instance: _InstanceT, value: _SetT) → None

    Set the attribute value.