-
-
Notifications
You must be signed in to change notification settings - Fork 385
attr.evolve does not handle custom __init__s #207
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
Comments
Yes, the new evolve depends on an appropriate Now, if you need the old functionality for whatever reason, you can always use copy.copy at your discretion, taking on all the caveats. Maybe we could stick this into the docs to help folks out. Making your own assoc-like using copy.copy is very simple:
It's just that we basically don't want to encourage or maintain this. |
Understood, I don't really want copying (and didn't / don't expect something like assoc to be trying to do it) -- in that model [without copying], there isn't really any caveats with the old functionality in my case AFAICT. I can definitely understand not wanting to maintain some code though :) -- do you think the no-copy model would be something attrs could support? If not, feel free to close obviously. |
Maybe we could just rename it so it’s clearer what it does? The function definitely isn’t a burden :) but I find the ambiguity problematic. |
I'm fine with renaming it obviously :P, but I don't have an immediate suggestion on a good name. |
attr.assoc
appears to have been deprecated in #169 and is now scheduled for removal in favor ofattr.evolve
, but the latter appears to not be able to do all that the former can do (and the documentation seems to indicate that this gap is intentional).Is there then a reason to deprecate the former, it seems like it should stay, or the functionality should go somewhere else? I can think of workarounds to change the way the below works, but want to make sure it's being broken intentionally -- as-is, it does work correctly with
attr.assoc
.Sample code:
for which
print f.assoc_new_other(new=13)
succeeds (but warns will go away) andf.evolve_new_other(new=13)
fails.The text was updated successfully, but these errors were encountered: