Description
- app-model version: 0.2.7
- Python version: 3.11
- Operating System: macOS Sonoma 14.5
Description
I'm working on upgrading napari settings from 0.4.19 to 0.5.0 in napari/napari#5316. This is my first encounter with the app-model keybindings so please bear with me. 😅 🙏
In our old settings (0.4.19), the settings were written out in an "OS-agnostic" way, e.g. "Control-Y" was the saved value for toggle_ndisplay, regardless of the operating system, and this was interpreted as Control-Y on Windows and Linux, and as Command-Y on macOS.
Since napari/napari#5103, which switched our keybindings settings to app-model, the keybinding is written out as Ctrl+Y on Windows/Linux and Meta+Y on macOS.
Arguably, Meta+Y
is an awkward hybrid of OS-independent and OS-dependent output, since "Meta" is not really a term used in macOS.
What I Did
In [13]: from app_model.types import KeyBinding
In [14]: KeyBinding.from_str('Cmd-Y')
Out[14]: <KeyBinding at 0x31079d8d0: Meta+Y>
In [15]: str(KeyBinding.from_str('Cmd-Y'))
Out[15]: 'Meta+Y'
I think that str should by default use the representation that makes sense for the current OS.
This is closely related to #89 but is more about the default representation of str() than about a special method.
Happy to submit a PR if there's agreement on this.