Skip to content

Replace dynamic uses of on_trait_change with observe part 2#663

Merged
aaronayres35 merged 18 commits into
masterfrom
replace-dynamic-otc-observe2
Mar 9, 2021
Merged

Replace dynamic uses of on_trait_change with observe part 2#663
aaronayres35 merged 18 commits into
masterfrom
replace-dynamic-otc-observe2

Conversation

@aaronayres35
Copy link
Copy Markdown
Contributor

part of #416

This PR finishes the job started in #656 by replacing the remaining dynamic uses of on_trait_change with observe.

@@ -93,7 +93,7 @@ def prepare(self, parent):
"""
name = self.extended_name
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BEWARE: extended_name

Copy link
Copy Markdown
Member

@jwiggins jwiggins Mar 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning what, exactly? We can't be sure that name won't break when passed to observe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a quick search of the code base for extended_name only gives this result here and the corresponding same thing in the wx file. Any downstream users that set this trait may run into problems if the extended name they are passing does not conform to the new mini language, and that is effectively out of our hands ...

A similar scenario was encountered in pyface and we mentioned it in the release announcement. I imagine the vast majority of users would not be affected (I dont even know how many users of this code we have in total). Nonetheless, it leaves a door open for potential breaks.

Another thing to worry about here though that I'm not sure what we would want to do for: The traitsUI code for Editor contains the code that would theoretically remove this listener (in either the dispose method or the _update_editor method itself. I also just realize I made a dumb mistake! The method being observed is _update_editor not update_editor which is defined in traitsUI. We are still in the process of updating traitsUI to observe, so that method will need its signature changed... I believe we will need that around first, before we can make this change as this code won't work currently. It must be uncovered in the test suite hence we don't see a failure here

Comment thread enable/abstract_window.py Outdated
Comment thread enable/abstract_window.py Outdated
@rahulporuri rahulporuri self-requested a review March 2, 2021 14:17
Comment thread enable/abstract_window.py Outdated
Comment thread enable/drawing/drawing_canvas.py Outdated
Comment thread enable/text_field.py Outdated
@aaronayres35 aaronayres35 changed the title Replace dynamic uses of on_trait_change with observe part 2 [WIP] Replace dynamic uses of on_trait_change with observe part 2 Mar 2, 2021
Copy link
Copy Markdown
Member

@jwiggins jwiggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The test for AbstractWindow looks fine.

Comment thread enable/abstract_window.py Outdated
Comment thread enable/savage/trait_defs/ui/qt4/svg_button_editor.py Outdated
@aaronayres35 aaronayres35 changed the title [WIP] Replace dynamic uses of on_trait_change with observe part 2 Replace dynamic uses of on_trait_change with observe part 2 Mar 9, 2021
@aaronayres35 aaronayres35 merged commit 2936fa8 into master Mar 9, 2021
@aaronayres35 aaronayres35 deleted the replace-dynamic-otc-observe2 branch March 9, 2021 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants