Skip to content

Commit 9cf3d33

Browse files
committed
Improve/harmonize docstrings
1 parent 447f8a4 commit 9cf3d33

File tree

7 files changed

+147
-150
lines changed

7 files changed

+147
-150
lines changed

docs/api.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,5 @@ All setters in ``attrs.setters`` are also available from ``attr.setters`` (it's
712712
...
713713
attrs.exceptions.FrozenAttributeError: ()
714714

715-
N.B. Please use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.
715+
.. tip::
716+
Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.

src/attr/_cmp.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ def cmp_using(
2626
The resulting class will have a full set of ordering methods if at least
2727
one of ``{lt, le, gt, ge}`` and ``eq`` are provided.
2828
29-
:param typing.Callable | None eq: `Callable` used to evaluate equality of two
29+
:param typing.Callable | None eq: Callable used to evaluate equality of two
3030
objects.
31-
:param typing.Callable | None lt: `Callable` used to evaluate whether one
31+
:param typing.Callable | None lt: Callable used to evaluate whether one
3232
object is less than another object.
33-
:param typing.Callable | None le: `Callable` used to evaluate whether one
33+
:param typing.Callable | None le: Callable used to evaluate whether one
3434
object is less than or equal to another object.
35-
:param typing.Callable | None gt: `Callable` used to evaluate whether one
35+
:param typing.Callable | None gt: Callable used to evaluate whether one
3636
object is greater than another object.
37-
:param typing.Callable | None ge: `Callable` used to evaluate whether one
37+
:param typing.Callable | None ge: Callable used to evaluate whether one
3838
object is greater than or equal to another object.
3939
4040
:param bool require_same_type: When `True`, equality and ordering methods

src/attr/_funcs.py

+25-28
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,21 @@ def asdict(
2222
Optionally recurse into other *attrs*-decorated classes.
2323
2424
:param inst: Instance of an *attrs*-decorated class.
25-
:param bool recurse: Recurse into classes that are also
26-
*attrs*-decorated.
27-
:param callable filter: A callable whose return code determines whether an
28-
attribute or element is included (``True``) or dropped (``False``). Is
29-
called with the `attrs.Attribute` as the first argument and the
30-
value as the second argument.
31-
:param callable dict_factory: A callable to produce dictionaries from. For
32-
example, to produce ordered dictionaries instead of normal Python
33-
dictionaries, pass in ``collections.OrderedDict``.
34-
:param bool retain_collection_types: Do not convert to ``list`` when
35-
encountering an attribute whose type is ``tuple`` or ``set``. Only
36-
meaningful if ``recurse`` is ``True``.
37-
:param Optional[callable] value_serializer: A hook that is called for every
38-
attribute or dict key/value. It receives the current instance, field
39-
and value and must return the (updated) value. The hook is run *after*
40-
the optional *filter* has been applied.
25+
:param bool recurse: Recurse into classes that are also *attrs*-decorated.
26+
:param ~typing.Callable filter: A callable whose return code determines
27+
whether an attribute or element is included (`True`) or dropped
28+
(`False`). Is called with the `attrs.Attribute` as the first argument
29+
and the value as the second argument.
30+
:param ~typing.Callable dict_factory: A callable to produce dictionaries
31+
from. For example, to produce ordered dictionaries instead of normal
32+
Python dictionaries, pass in ``collections.OrderedDict``.
33+
:param bool retain_collection_types: Do not convert to `list` when
34+
encountering an attribute whose type is `tuple` or `set`. Only
35+
meaningful if *recurse* is `True`.
36+
:param typing.Callable | None value_serializer: A hook that is called for
37+
every attribute or dict key/value. It receives the current instance,
38+
field and value and must return the (updated) value. The hook is run
39+
*after* the optional *filter* has been applied.
4140
4241
:rtype: return type of *dict_factory*
4342
@@ -207,18 +206,16 @@ def astuple(
207206
Optionally recurse into other *attrs*-decorated classes.
208207
209208
:param inst: Instance of an *attrs*-decorated class.
210-
:param bool recurse: Recurse into classes that are also
211-
*attrs*-decorated.
212-
:param callable filter: A callable whose return code determines whether an
213-
attribute or element is included (``True``) or dropped (``False``). Is
214-
called with the `attrs.Attribute` as the first argument and the
215-
value as the second argument.
216-
:param callable tuple_factory: A callable to produce tuples from. For
217-
example, to produce lists instead of tuples.
218-
:param bool retain_collection_types: Do not convert to ``list``
219-
or ``dict`` when encountering an attribute which type is
220-
``tuple``, ``dict`` or ``set``. Only meaningful if ``recurse`` is
221-
``True``.
209+
:param bool recurse: Recurse into classes that are also *attrs*-decorated.
210+
:param ~typing.Callable filter: A callable whose return code determines
211+
whether an attribute or element is included (`True`) or dropped
212+
(`False`). Is called with the `attrs.Attribute` as the first argument
213+
and the value as the second argument.
214+
:param ~typing.Callable tuple_factory: A callable to produce tuples from.
215+
For example, to produce lists instead of tuples.
216+
:param bool retain_collection_types: Do not convert to `list` or `dict`
217+
when encountering an attribute which type is `tuple`, `dict` or `set`.
218+
Only meaningful if *recurse* is `True`.
222219
223220
:rtype: return type of *tuple_factory*
224221

0 commit comments

Comments
 (0)