From 95b70bde2ed18f4ddd78cb42ebc0bb578f111b56 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Thu, 28 Oct 2021 07:00:01 +0200 Subject: [PATCH] Clarify that validators/converters only run on init --- docs/examples.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/examples.rst b/docs/examples.rst index 0fac312a..4e40fac3 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -440,6 +440,9 @@ Therefore if you use ``@attr.s(auto_attribs=True)``, it is *not* enough to decor ... TypeError: ("'x' must be (got '42' that is a ).", Attribute(name='x', default=NOTHING, factory=NOTHING, validator=>, type=None, kw_only=False), , '42') +Please note that if you use `attr.s` (and not `attr.define`) to define your class, validators only run on initialization by default. +This behavior can be changed using the ``on_setattr`` argument. + Check out `validators` for more details. @@ -458,6 +461,8 @@ This can be useful for doing type-conversions on values that you don't want to f >>> o.x 1 +Please note that converters only run on initialization. + Check out `converters` for more details.