Name Description Size
__init__.py Classes Without Boilerplate 2057
__init__.pyi 11281
_cmp.py Create a class that can be passed into `attrs.field`'s ``eq``, ``order``, and ``cmp`` arguments to customize field comparison. The resulting class will have a full set of ordering methods if at least one of ``{lt, le, gt, ge}`` and ``eq`` are provided. Args: eq (typing.Callable | None): Callable used to evaluate equality of two objects. lt (typing.Callable | None): Callable used to evaluate whether one object is less than another object. le (typing.Callable | None): Callable used to evaluate whether one object is less than or equal to another object. gt (typing.Callable | None): Callable used to evaluate whether one object is greater than another object. ge (typing.Callable | None): Callable used to evaluate whether one object is greater than or equal to another object. require_same_type (bool): When `True`, equality and ordering methods will return `NotImplemented` if objects are not of the same type. class_name (str | None): Name of class. Defaults to "Comparable". See `comparison` for more details. .. versionadded:: 21.1.0 4117
_cmp.pyi 368
_compat.py Get annotations for *cls*. 2704
_config.py Set whether or not validators are run. By default, they are run. .. deprecated:: 21.3.0 It will not be removed, but it also will not be moved to new ``attrs`` namespace. Use `attrs.validators.set_disabled()` instead. 843
_funcs.py Return the *attrs* attribute values of *inst* as a dict. Optionally recurse into other *attrs*-decorated classes. Args: inst: Instance of an *attrs*-decorated class. recurse (bool): Recurse into classes that are also *attrs*-decorated. filter (~typing.Callable): A callable whose return code determines whether an attribute or element is included (`True`) or dropped (`False`). Is called with the `attrs.Attribute` as the first argument and the value as the second argument. dict_factory (~typing.Callable): A callable to produce dictionaries from. For example, to produce ordered dictionaries instead of normal Python dictionaries, pass in ``collections.OrderedDict``. retain_collection_types (bool): Do not convert to `list` when encountering an attribute whose type is `tuple` or `set`. Only meaningful if *recurse* is `True`. value_serializer (typing.Callable | None): A hook that is called for every attribute or dict key/value. It receives the current instance, field and value and must return the (updated) value. The hook is run *after* the optional *filter* has been applied. Returns: Return type of *dict_factory*. Raises: attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. versionadded:: 16.0.0 *dict_factory* .. versionadded:: 16.1.0 *retain_collection_types* .. versionadded:: 20.3.0 *value_serializer* .. versionadded:: 21.3.0 If a dict has a collection for a key, it is serialized as a tuple. 15854
_make.py Sentinel to indicate the lack of a value when `None` is ambiguous. If extending attrs, you can use ``typing.Literal[NOTHING]`` to show that a value may be ``NOTHING``. .. versionchanged:: 21.1.0 ``bool(NOTHING)`` is now False. .. versionchanged:: 22.2.0 ``NOTHING`` is now an ``enum.Enum`` variant. 96664
_next_gen.py These are keyword-only APIs that call `attr.s` and `attr.ib` with different default values. 24395
_typing_compat.pyi 469
_version_info.py A version object that can be compared to tuple of length 1--4: >>> attr.VersionInfo(19, 1, 0, "final") <= (19, 2) True >>> attr.VersionInfo(19, 1, 0, "final") < (19, 1, 1) True >>> vi = attr.VersionInfo(19, 2, 0, "final") >>> vi < (19, 1, 1) False >>> vi < (19,) False >>> vi == (19, 2,) True >>> vi == (19, 2, 1) False .. versionadded:: 19.2 2121
_version_info.pyi 209
converters.py Commonly useful converters. 3861
converters.pyi 643
exceptions.py A frozen/immutable instance or attribute have been attempted to be modified. It mirrors the behavior of ``namedtuples`` by using the same error message and subclassing `AttributeError`. .. versionadded:: 20.1.0 1977
exceptions.pyi 539
filters.py Commonly useful filters for `attrs.asdict` and `attrs.astuple`. 1795
filters.pyi 208
py.typed 0
setters.py Commonly used hooks for on_setattr. 1617
setters.pyi 584
validators.py Commonly useful validators. 20046
validators.pyi 2603