-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Restore widget shortcuts to Preferences and allow to change them on the fly (Shortcuts) #23024
Conversation
251ca02
to
8b3fe55
Compare
8b3fe55
to
b18dc1a
Compare
@dalthviz, this is ready for review. Please check that:
|
Gave this an initial check and seems like manually changing shortcuts is working and also shortcuts like |
The current docstrings were not easy to understand.
- The previous solution, which used tuples to collect those data, was easy to break, because it required to put data in the right order; and undocumented, because it was unclear what kind of data had to be added in the tuple elements. - Those limitations made difficult to reason about shortcuts-related code.
b18dc1a
to
1f336d9
Compare
- Before we only allowed class methods decorated with on_conf_change to do that. - But that's too limited if we need to use regular functions to observe an option. And that's precisely what this new method allows us to do.
This is necessary to add observers for specific shortcuts.
- That allows those shortcuts to be updated on the fly when they are changed in Preferences or directly with set_conf. - Also, fix inheritance of classes that inherit from SpyderShortcutsMixin to accomodate this change.
That was introducing an error in test_shortcut_for_widget_is_updated when run on CI due to the incorrectly named section.
This is to have feature parity of kwargs with the other methods of SpyderShortcutsMixin.
Also, add inline typing for several attributes of ConfigurationManager and remove associated comments.
1f336d9
to
b8d84e8
Compare
Thanks for checking that @dalthviz! It should be fixed now. I also took the opportunity to change the context of the Switcher shortcut actions to be |
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 @ccordoba12 ! Gave another local check to the reset shortcuts to default values and seems like things are working as expected now. Left a couple of questions and couple of suggestions like using an f-string at somepoint and an idea to extend a test but other than that this LGTM 👍
Also, remove some extra valid contexts that are not necessary anymore.
615f1ac
to
b0d9c04
Compare
b0d9c04
to
47ee224
Compare
- That prevents third-party plugin developers to set shortcuts that can't be processed by Spyder. - Print errors when instantiating CONF to allow third-party developers understand what's wrong with it. - Use an f-string when setting shortcuts for clarity.
Hello @ccordoba12! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-11-30 16:21:36 UTC |
43ef693
to
7b1a3fe
Compare
@dalthviz, this is ready for another review. Besides addressing your comments, I also took the opportunity to fix other problems with shortcuts I found while doing that in my last four commits. Specifically, I:
|
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 @ccordoba12 ! Left a question regarding the usage of print
instead of the login module in some error handling but other than that this seems like ready to be merged 👍
Will leave this approved so feel free to merge this is you think is ready.
|
||
try: | ||
CONF = ConfigurationManager() | ||
except Exception: | ||
from qtpy.QtWidgets import QApplication, QMessageBox | ||
|
||
# Print traceback to show error in the terminal in case it's needed | ||
print(traceback.format_exc()) # spyder: test-skip |
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.
Shouldn't we use the logging module for this?
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.
@meeseeksdev please backport to 6.x |
…nces and allow to change them on the fly (Shortcuts)
…ferences and allow to change them on the fly (Shortcuts)) (#23137)
Description of Changes
ShortcutData
dataclass to represent shortcut data internally and work more easily with it._
, i.e. global (before their context wasswitcher
but that made little sense).Issue(s) Resolved
Fixes #23072
Fixes #22741
Fixes #22516
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: @ccordoba12