One use-case I have where __setattr__
would be useful is for a configuration attribute that at one point had permissible values True
, False
and 'auto'
. 'auto'
was deprecated, but the DeprecationWarning
is only emitted when someone tries to use a function that depends on that value. With __setattr__
, I would be able to emit a warning at the point someone tries to set a deprecated value. One can imagine a case where a downstream tool sets the value, but only a few users ever trigger the behavior, so it might not get caught through normal inspection of test logs.
1 Like