diff --git a/.flake8 b/.flake8 index ceee4512ca2..580aa6670a1 100644 --- a/.flake8 +++ b/.flake8 @@ -25,12 +25,6 @@ per-file-ignores = doc/python/m.distance.py: E501 doc/gui/wxpython/example/dialogs.py: F401 gui/scripts/d.wms.py: E501 - gui/wxpython/gui_core/*: E722 - gui/wxpython/gui_core/dialogs.py: E722 - gui/wxpython/gui_core/forms.py: E722 - gui/wxpython/gui_core/ghelp.py: E722 - gui/wxpython/gui_core/gselect.py: E722 - gui/wxpython/gui_core/widgets.py: E722 gui/wxpython/image2target/*: F841, E722 gui/wxpython/image2target/g.gui.image2target.py: E501, F841 gui/wxpython/iscatt/*: F841, E722, F405, F403 diff --git a/gui/wxpython/gui_core/dialogs.py b/gui/wxpython/gui_core/dialogs.py index f7c7711cadf..cd2a8dcc24d 100644 --- a/gui/wxpython/gui_core/dialogs.py +++ b/gui/wxpython/gui_core/dialogs.py @@ -1213,7 +1213,7 @@ def _filter(self, data): try: if re.compile(self.flt_pattern).search(dt): flt_data.append(dt) - except: + except re.error: pass return flt_data @@ -1656,7 +1656,7 @@ def OnFilter(self, event): try: if re.compile(event.GetString()).search(layer): list.append(layer) - except: + except re.error: pass list = naturally_sorted(list) diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 1ef623feaf7..c1123497abf 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -2016,7 +2016,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar # check wildcard try: fExt = os.path.splitext(p.get("key_desc", ["*.*"])[0])[1] - except: + except IndexError: fExt = None if not fExt: fMask = "*" diff --git a/gui/wxpython/gui_core/ghelp.py b/gui/wxpython/gui_core/ghelp.py index 6713dbcc0a3..0c4f6cdadfb 100644 --- a/gui/wxpython/gui_core/ghelp.py +++ b/gui/wxpython/gui_core/ghelp.py @@ -566,15 +566,15 @@ def _langString(self, k, v): allStr = "%s :" % k.upper() try: allStr += _(" %d translated") % v["good"] - except: + except KeyError: pass try: allStr += _(" %d fuzzy") % v["fuzzy"] - except: + except KeyError: pass try: allStr += _(" %d untranslated") % v["bad"] - except: + except KeyError: pass return allStr @@ -589,7 +589,7 @@ def _langBox(self, par, k, v): ) tgood.SetForegroundColour(wx.Colour(35, 142, 35)) langBox.Add(tgood) - except: + except KeyError: tgood = StaticText(parent=par, id=wx.ID_ANY, label="") langBox.Add(tgood) try: @@ -598,7 +598,7 @@ def _langBox(self, par, k, v): ) tfuzzy.SetForegroundColour(wx.Colour(255, 142, 0)) langBox.Add(tfuzzy) - except: + except KeyError: tfuzzy = StaticText(parent=par, id=wx.ID_ANY, label="") langBox.Add(tfuzzy) try: @@ -607,7 +607,7 @@ def _langBox(self, par, k, v): ) tbad.SetForegroundColour(wx.Colour(255, 0, 0)) langBox.Add(tbad) - except: + except KeyError: tbad = StaticText(parent=par, id=wx.ID_ANY, label="") langBox.Add(tbad) return langBox @@ -844,7 +844,7 @@ def fillContentsFromFile(self, htmlFile, skipDescription=True): contents.append(line) self.SetPage("".join(contents)) self.loaded = True - except: # The Manual file was not found + except Exception: # The Manual file was not found self.loaded = False diff --git a/gui/wxpython/gui_core/gselect.py b/gui/wxpython/gui_core/gselect.py index af71cc4f550..ec873f60eb4 100644 --- a/gui/wxpython/gui_core/gselect.py +++ b/gui/wxpython/gui_core/gselect.py @@ -484,7 +484,7 @@ def GetElementList(self, elements=None, exclude=False): try: self.seltree.EnsureVisible(item) self.seltree.SelectItem(item) - except: + except Exception: pass def _getElementList(self, element, mapsets=None, elements=None, exclude=False): diff --git a/gui/wxpython/gui_core/widgets.py b/gui/wxpython/gui_core/widgets.py index 5f2582f9b1e..dc9041e3578 100644 --- a/gui/wxpython/gui_core/widgets.py +++ b/gui/wxpython/gui_core/widgets.py @@ -752,7 +752,7 @@ def _validate(self, win): if text: try: datetime.strptime(text, "%Y-%m-%d") - except: + except ValueError: self._notvalid() return False