Skip to content

Commit

Permalink
Clarify execution order in init
Browse files Browse the repository at this point in the history
Fixes #461
  • Loading branch information
hynek committed Jan 22, 2019
1 parent af35f2a commit a09ea0e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,23 @@ If you need to set attributes on a frozen class, you'll have to resort to the :r

Note that you *must not* access the hash code of the object in ``__attrs_post__init__`` if ``cache_hash=True``.


Order of Execution
------------------

If present, the hooks are executed in the following order:

1. For each attribute:

a. default factory
b. converter

2. *all* validators
3. ``__attrs_post_init__``

Notably this means, that you can access all attributes from within your validators, but your converters have to deal with invalid values and have to return a valid value.


.. _`Wiki page`: https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs
.. _`get confused`: https://github.com/python-attrs/attrs/issues/289
.. _`there is no such thing as a private argument`: https://github.com/hynek/characteristic/issues/6

0 comments on commit a09ea0e

Please sign in to comment.