-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fix TraitError when mutating a list/dict/set inside another container #1018
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.
This is not a long fix, so maybe it would be good to add the fix to Set
and Dict
implementations in this PR as well?
Happy to do that, then we close issue #25 in one go! |
I have expanded the fix for All the added tests failed on the commit before #913 was merged: Test failures at c91e91e
At the commit when #913 was merged, these tests pass:
That state is the same with the current master. Note that I did not solve the traits/traits/trait_handlers.py Lines 1127 to 1135 in 77cbf0a
I'd prefer doing that separately because the cause is different, even though the symptom looks the same. |
I also updated the main description for this PR. |
This is the bit that worries me:
The (original) behaviour is considered a bug, but it is also conceivable that it is a bug being exploited. I am going to run this branch against a sizeable project and see if this breaks things. |
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.
Thanks for implementing the fix for all three traits!
The code and the tests LGTM apart from a couple minor comments.
Nothing broke for the project I tried. :) From offline discussion, this existing behaviour is a documented bug so we should go ahead to fix. Prior to the release, we will assess whether this causes any massive, hard-to-fix breakage. So far there are no evidence that this will. |
Thank you @ievacerny! Merging... |
Fix the TraitError when:
Dict(Any, Union(None, List))
Behaviour change:
list_of_list = List(List)
will fire an item change onlist_of_list_items
. Similarly forDict(Any, Dict)
.Closes #25
Note that this does NOT resolve the same error seen when
Set
andDict
is wrapped insideEither
in #278. That error is caused by something else.EDITED:
The issue was closed as a duplicate of #25, but this PR does NOT close #25 because the same fix has not been applied toTraitDictObject
, which is currently being refactored in #913.Also thanks to @midhun-pm for his previous work related to this, on #951
Checklist
Update API reference (docs/source/traits_api_reference
)Update User manual (docs/source/traits_user_manual
)Update type annotation hints intraits-stubs