-
Notifications
You must be signed in to change notification settings - Fork 815
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
Return 'self' in some widget verb methods. #2102
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I compiled a list of all widget methods that return 'None' and for which it _could_ make sense to make this change. (I filtered out some methods, like watch and action methods.) I tried choosing a subset of those methods, trying to only pick methods for which there weren't two things that could be returned (e.g., 'Widget.move_child' _could_ return either the widget or the child that was moved) and I also tried to only pick methods that have little or no parameters (e.g., 'Widget.animate' has many parameters and is typically called with quite a few. These are all the 'Widget' methods for which this could make sense: - 'move_child' (either return 'self' or the actual 'child' that was moved…) - 'animate' - 'scroll_to' / 'scroll_relate' / 'scroll_home' / 'scroll_end' / 'scroll_left' / 'scroll_right' / 'scroll_down' / 'scroll_up' / 'scroll_page_up' / 'scroll_page_down' / 'scroll_page_left' / 'scroll_page_right' / 'scroll_visible' - 'refresh' - 'focus' / 'reset_focus' - 'capture_mouse' / 'release_mouse' Additionally, I looked at each widget, and found these methods: - 'Tree' - 'TreeNode' - 'expand' / 'expand_all' / 'collapse' / 'collapse_all' / 'toggle' / 'toggle_all' - 'set_label' - 'clear' / 'reset' - 'select_node' (either return 'self' or the actual 'node' that was selected) - 'scroll_to_line' / 'scroll_to_node' - 'refresh_line' - 'ToggleButton' - 'toggle' (and 'action_toggle'?) - 'TextLog' - 'write' - 'clear' - 'Tabs' - 'add_tab' / 'remove_tab' - 'clear' - 'Switch' - 'toggle' (and 'action_toggle'?) - 'Static' - 'update' - 'Pretty' - 'update' - 'Placeholder' - 'cycle_variant' - '_markdown.py' - 'MarkdownBlock' - 'set_content' - 'MarkdownTableOfContents' - 'set_table_of_contents' - 'Input' - 'insert_text_at_cursor' - 'DirectoryTree' - 'load_directory' - 'DataTable' - 'update_cell' / 'update_cell_at' - 'clear' - 'refresh_coordinate' / 'refresh_row' / 'refresh_column' - 'sort' - 'Button' - 'press' Related issues: #1908 Related discussions: #1817
davep
reviewed
Mar 22, 2023
willmcgugan
requested changes
Mar 23, 2023
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.
Looks good. But I think it would be best to always explicitly return self
, rather than return the result of another method.
That makes sense. |
willmcgugan
approved these changes
Mar 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I compiled a list of all widget methods that return
None
and for which it could make sense to make this change. (I filtered out some methods, like watch and action methods.)I tried choosing a subset of those methods, trying to only pick methods for which there weren't two things that could be returned (e.g.,
Widget.move_child
could return either the widget or the child that was moved) and I also tried to only pick methods that have little or no parameters (e.g.,Widget.animate
has many parameters and is typically called with quite a few.)These are all the
Widget
methods for which this could make sense:move_child
(either returnself
or the actualchild
that was moved…)animate
scroll_to
/scroll_relate
/scroll_home
/scroll_end
/scroll_left
/scroll_right
/scroll_down
/scroll_up
/scroll_page_up
/scroll_page_down
/scroll_page_left
/scroll_page_right
/scroll_visible
refresh
focus
/reset_focus
capture_mouse
/release_mouse
Additionally, I looked at each widget, and found these methods:
Tree
TreeNode
expand
/expand_all
/collapse
/collapse_all
/toggle
/toggle_all
set_label
clear
/reset
select_node
(either returnself
or the actualnode
that was selected)scroll_to_line
/scroll_to_node
refresh_line
ToggleButton
toggle
(andaction_toggle
?)TextLog
write
clear
Tabs
add_tab
/remove_tab
clear
Switch
toggle
(andaction_toggle
?)Static
update
Pretty
update
Placeholder
cycle_variant
_markdown.py
MarkdownBlock
set_content
MarkdownTableOfContents
set_table_of_contents
Input
insert_text_at_cursor
DirectoryTree
load_directory
DataTable
update_cell
/update_cell_at
clear
refresh_coordinate
/refresh_row
/refresh_column
sort
Button
press
Related issues: #1908
Related discussions: #1817