Skip to content

Commit

Permalink
Add stern warning that nobody will read
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Mar 13, 2020
1 parent 85f36fc commit 379f284
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog.d/607.change.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
``attrs`` can now automatically detect your own implementations and infer ``init=False``, ``repr=False``, ``eq=False``, ``order=False``, and ``hash=False`` if you set ``@attr.s(auto_detect=True)``.
``attrs`` will ignore inherited methods.
If the argument implies more than one methods (e.g. ``eq=True`` creates both ``__eq__`` and ``__ne__``), it's enough for *one* of them to exist and ``attrs`` will create *neither*.
If the argument implies more than one method (e.g. ``eq=True`` creates both ``__eq__`` and ``__ne__``), it's enough for *one* of them to exist and ``attrs`` will create *neither*.

This feature requires Python 3.
12 changes: 11 additions & 1 deletion src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,17 @@ def attrs(
So for example by implementing ``__eq__`` on a class yourself,
``attrs`` will deduce ``eq=False`` and won't create *neither*
``__eq__`` *nor* ``__ne__``.
``__eq__`` *nor* ``__ne__`` (but Python classes come with a sensible
``__ne__`` by default, so it *should* be enough to only implement
``__eq__`` in most cases).
.. warning::
If you prevent ``attrs`` from creating the ordering methods for you
(``order=False``, e.g. by implementing ``__le__``), it becomes
*your* responsibility to make sure its ordering is sound. The best
way is to use the `functools.total_ordering` decorator.
Passing ``True`` or ``False`` to *init*, *repr*, *eq*, *order*,
*cmp*, or *hash* overrides whatever *auto_detect* would determine.
Expand Down

0 comments on commit 379f284

Please sign in to comment.