-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add on_setattr hooks to attr.s and attr.ib #660
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only looked at the type stuff and made some suggestions. Though I wonder if the typevars I'm suggesting are more trouble than they're worth.
Signed-off-by: Hynek Schlawack <[email protected]>
DISABLE sounds less purposeful and doesn't convey its meaning as well.
Since there was no more feedback, I'm YOLO-timeouting this. If someone wants to chime in before the release feel free. |
Hi @hynek, I wonder if we have any release plan for this fix? We're having some use-cases which requires this and we're eagerly looking for it to be released. If anything we can help to make it release sooner, can you let us know? |
#666 is the last remaining part of the puzzle. I hope I’ll be able to release this week. |
Sounds great, thanks so much @hynek |
This fixes #645 and a billion other issues that asked for freezing attributes and validation on assignment.
I'm not married to all the names and open to better suggestions.
Yes, it was more work to integrate than anticipated. 😳
While working on this I've also noticed that we take no precaution about
__setattr__
being inherited, which means that if you subclass a frozen class, you can't easily thaw it. This topic is somewhat related to this PR too but I didn't want to bloat it any further. It goes down to setting__setattr__
toobject.__setattr__
if we don't write an own, but ifauto_detect
is true, only if the user didn't write one?