Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 RangeEditor support for format_func #1684
Add RangeEditor support for format_func #1684
Changes from 9 commits
dd82eec
cf42ce4
d25a17f
fc9ae39
3032065
017714b
7383f01
9ad59b8
bb7a3c4
f4fc4b0
a7304b0
cd26554
68c42f1
d618dde
2bf3fa5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 was thinking this should become a property that mirrors the editors
factory_str
but I don't think that is needed / allowed? (ie an instance of an editor can't set its factory's trait). We ultimately had previously just setself.format = factory.format
in theinit
method anyways.I am worried there may be a change in behavior if a user was to try to set
format
on an instance of aRangeEditor
. e.gmy_editor = RangeEditor()
,my_editor.format = "something"
. Previously, because we had been usingself.format
throughout instead ofstring_value
, so this would actually be used. Now, AFAICT, the best we can do is pass it as a kwarg tostring_value
if a user tries to set it on an instance, but that will no longer take priority if the factory has its trait set...I don't think we want to change any behavior here (even if the current behavior is strange). I am unsure how to best move forward.
@rahulporuri any thoughts on this? I hope my explanation made some sense, if not we can discuss tomorrow at standup
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.
So initially I expected this Test to pass on master, but fail on this branch:
but it passes on both. I then realized
my_editor
is always just an instance of thetraitsui.editors.RangeEditor
EditorFactory
. The actualEditor
instances are only created when e.g. the_get_simple_editor_class
method is called. If I access theEditor
directly, e.g. doing something like this:I expected it to pass on master and fail on this branch. However, this fails on both...
So, AFAICT, behavior is not changed by this PR.
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.
EDIT: see the recently added test
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.
Can you search for users of the
format
trait on this editor? I'm not even sure how one would go about specifically searching for such uses. Whether or not users exist would help us decide on whether or not we need to convertformat
into a property as well - and make getting/settingformat
raise warnings as well.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 was unable to find any users trying to set format on the Editor instance directly.
I did see users setting it on the Factory object, ie
RangeEditor(format= ...)
, but that is covered by the use of property/deprecation intraitsui/editors/range_editor.py
.TBH I am not certain what the pattern would be to set it on the Editor instance. I guess accessing it through
UIInfo
?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.
From traitsUI docs: "Note that not every trait on every editor can react to changes: some values are only used at editor creation time; however all editors support dynamically changing the enabled, visible and invalid traits. This feature can sometimes allow developers to avoid having to create a custom Handler subclass."