eradiate.attrs
#
attrs-based utility classes and functions.
Attributes#
- eradiate.attrs.AUTO#
Sentinel to indicate when a dynamic field value is expected to be set automatically.
Attribute docs extension#
- eradiate.attrs.define(maybe_cls=None, **kwargs)[source]#
A wrapper around
attrs.define()
that automatically applies docstring processing withparse_docs()
. All arguments are forwarded toattrs.define()
.
- eradiate.attrs.frozen(maybe_cls=None, **kwargs)[source]#
A wrapper around
attrs.frozen()
that automatically applies docstring processing withparse_docs()
. All arguments are forwarded toattrs.frozen()
.
- eradiate.attrs.parse_docs(cls)[source]#
Extract attribute documentation and update class docstring with it.
This decorator will examine each attrs attribute and check its metadata for documentation content. It will then update the class’s docstring based on this content.
See also
documented()
Field documentation definition function.
Notes
Meant to be used as a class decorator.
Must be applied after
@attr.s
(or any other attrs decorator).Fields must be documented using
documented()
.
- eradiate.attrs.documented(attrib, doc=None, type=None, init_type=None, default=None)[source]#
Declare an attrs field as documented.
- Parameters:
attrib (
attrs.Attribute
) – attrs attribute definition to which documentation is to be attached.doc (
str
, optional) – Docstring for the considered field. If set toNone
, this function does nothing.type (
str
, optional) – Documented type for the considered field.init_type (
str
, optional) – Documented constructor parameter for the considered field.default (
str
, optional) – Documented default value for the considered field.
- Returns:
attrs.Attribute
–attrib
, with metadata updated with documentation contents.
See also
attrs.field()
,pinttr.field()
,parse_docs()
- eradiate.attrs.get_doc(cls, attrib, field)[source]#
Fetch attribute documentation field. Requires field metadata to be processed with
documented()
.- Parameters:
- Returns:
str
– Queried documentation content.- Raises:
ValueError – If the requested
field
is missing from the target attribute’s metadata.ValueError – If the requested
field
is unsupported.