Skip to content

Commit

Permalink
Decouple these docs from properties
Browse files Browse the repository at this point in the history
Fixes #177
  • Loading branch information
hynek committed May 10, 2017
1 parent dcba01d commit d02b1d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
18 changes: 0 additions & 18 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ This is useful in times when you want to enhance classes that are not yours (nic
>>> SomethingFromSomeoneElse(1)
SomethingFromSomeoneElse(x=1)

Or if you want to use properties:

.. doctest::

>>> @attr.s(these={"_x": attr.ib()})
... class ReadOnlyXSquared(object):
... @property
... def x(self):
... return self._x ** 2
>>> rox = ReadOnlyXSquared(x=5)
>>> rox
ReadOnlyXSquared(_x=5)
>>> rox.x
25
>>> rox.x = 6
Traceback (most recent call last):
...
AttributeError: can't set attribute

`Subclassing <https://www.youtube.com/watch?v=3MNVP9-hglc>`_ is bad for you, but ``attrs`` will still do what you'd hope for:

Expand Down
6 changes: 3 additions & 3 deletions src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ def attributes(maybe_cls=None, these=None, repr_ns=None,
:param these: A dictionary of name to :func:`attr.ib` mappings. This is
useful to avoid the definition of your attributes within the class body
because you can't (e.g. if you want to add ``__repr__`` methods to
Django models) or don't want to (e.g. if you want to use
:class:`properties <property>`).
Django models) or don't want to.
If *these* is not ``None``, the class body is *ignored*.
If *these* is not ``None``, ``attrs`` will *not* search the class body
for attributes.
:type these: :class:`dict` of :class:`str` to :func:`attr.ib`
Expand Down

0 comments on commit d02b1d8

Please sign in to comment.