--- a/eric6/Preferences/Shortcuts.py Thu Apr 15 16:52:05 2021 +0200 +++ b/eric6/Preferences/Shortcuts.py Thu Apr 15 18:11:24 2021 +0200 @@ -7,6 +7,8 @@ Module implementing functions dealing with keyboard shortcuts. """ +import contextlib + from PyQt5.QtCore import QFile, QIODevice, QCoreApplication from PyQt5.QtGui import QKeySequence @@ -95,15 +97,12 @@ __readShortcut(act, helpViewerCategory, prefClass) if pluginName is not None: - try: + with contextlib.suppress(KeyError): ref = e5App().getPluginObject(pluginName) if hasattr(ref, "getActions"): actions = ref.getActions() for act in actions: __readShortcut(act, pluginName, prefClass) - except KeyError: - # silently ignore non available plugins - pass def __saveShortcut(act, category, prefClass): @@ -292,13 +291,11 @@ """ for act in actions: if act.objectName(): - try: + with contextlib.suppress(KeyError): accel, altAccel = shortcutsDict[act.objectName()] act.setShortcut(QKeySequence(accel)) act.setAlternateShortcut(QKeySequence(altAccel), removeEmpty=True) - except KeyError: - pass def setActions(shortcuts, helpViewer=None):