--- a/eric6/Project/Project.py Wed Apr 14 19:38:19 2021 +0200 +++ b/eric6/Project/Project.py Wed Apr 14 19:59:16 2021 +0200 @@ -14,6 +14,7 @@ import fnmatch import copy import zipfile +import contextlib from PyQt5.QtCore import ( pyqtSlot, QFile, QFileInfo, pyqtSignal, QCryptographicHash, QIODevice, @@ -644,13 +645,11 @@ self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" # Project type specific ones - try: + with contextlib.suppress(KeyError): if self.__fileTypeCallbacks[ self.pdata["PROJECTTYPE"]] is not None: ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() self.pdata["FILETYPES"].update(ftypes) - except KeyError: - pass self.setDirty(True) @@ -668,7 +667,7 @@ self.pdata["FILETYPES"]["*.ts"] = "TRANSLATIONS" if "*.qm" not in self.pdata["FILETYPES"]: self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" - try: + with contextlib.suppress(KeyError): if self.__fileTypeCallbacks[ self.pdata["PROJECTTYPE"]] is not None: ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"]]() @@ -676,8 +675,6 @@ if pattern not in self.pdata["FILETYPES"]: self.pdata["FILETYPES"][pattern] = ftype self.setDirty(True) - except KeyError: - pass def __loadRecent(self): """ @@ -2920,11 +2917,9 @@ # try project type specific defaults next projectType = self.pdata["PROJECTTYPE"] - try: + with contextlib.suppress(KeyError): if self.__lexerAssociationCallbacks[projectType] is not None: return self.__lexerAssociationCallbacks[projectType](filename) - except KeyError: - pass # return empty string to signal to use the global setting return "" @@ -4782,10 +4777,8 @@ @param actions list of actions (list of E5Action) """ for act in actions: - try: + with contextlib.suppress(ValueError): self.actions.remove(act) - except ValueError: - pass def getMenu(self, menuName): """