Skip to content

Commit

Permalink
Fix E722 do not use bare except
Browse files Browse the repository at this point in the history
  • Loading branch information
mshukuno committed May 28, 2024
1 parent 2bdcc05 commit 2b60b99
Show file tree
Hide file tree
Showing 70 changed files with 247 additions and 267 deletions.
108 changes: 44 additions & 64 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ per-file-ignores =
# F841 local variable assigned to but never used
# E741 ambiguous variable name 'l'
__init__.py: F401, F403
lib/init/grass.py: E722, F821, F841, W605
lib/init/grass.py: F821, F841, W605
utils/mkrest.py: W605
utils/gitlog2changelog.py: E722, E712, W605
utils/gitlog2changelog.py: E712, W605
utils/g.html2man/ggroff.py: W605
man/build_check_rest.py: F403, F405
man/build_full_index_rest.py: F403, F405
Expand All @@ -33,93 +33,81 @@ per-file-ignores =
man/build_full_index.py: F403, F405
man/build_index.py: F403, F405
man/build_index_rest.py: F403, F405
man/build_keywords.py: F403, F405, E722
man/build_topics.py: F403, F405, E722
man/build_keywords.py: F403, F405
man/build_topics.py: F403, F405
man/build_html.py: E501
imagery/i.atcorr/create_iwave.py: F632, F821, W293
doc/python/raster_example_ctypes.py: F403, F405
doc/python/vector_example_ctypes.py: F403, F405
doc/python/m.distance.py: F403, F405, E501
doc/gui/wxpython/example/dialogs.py: F401
locale/grass_po_stats.py: E122, E128, E231, E401, E722, E741
locale/grass_po_stats.py: E122, E128, E231, E401, E741
gui/scripts/d.wms.py: E501
gui/wxpython/core/gcmd.py: E402
gui/wxpython/core/gthread.py: F841
gui/wxpython/core/gconsole.py: E722, W605
gui/wxpython/core/gconsole.py: W605
gui/wxpython/core/globalvar.py: W605
gui/wxpython/core/toolboxes.py: E722
gui/wxpython/core/utils.py: E722, F841, W605
gui/wxpython/core/workspace.py: E722
gui/wxpython/core/render.py: E722, F841
gui/wxpython/core/utils.py: F841, W605
gui/wxpython/core/render.py: F841
gui/wxpython/core/ws.py: F841
gui/wxpython/core/settings.py: E722
gui/wxpython/core/watchdog.py: E402
gui/wxpython/datacatalog/tree.py: E731, E402
gui/wxpython/dbmgr/base.py: E722, F841
gui/wxpython/dbmgr/dialogs.py: F841, E722
gui/wxpython/dbmgr/sqlbuilder.py: E722, F841
gui/wxpython/dbmgr/manager.py: E722
gui/wxpython/dbmgr/base.py: F841
gui/wxpython/dbmgr/dialogs.py: F841
gui/wxpython/dbmgr/sqlbuilder.py: F841
gui/wxpython/dbmgr/vinfo.py: F841
gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291
gui/wxpython/gcp/g.gui.gcp.py: F841
gui/wxpython/gcp/manager.py: F841, E722
gui/wxpython/gcp/manager.py: F841
gui/wxpython/gcp/mapdisplay.py: F841
gui/wxpython/gui_core/*: F841, E266, E722, W605
gui/wxpython/gui_core/dialogs.py: E722, F841, W605
gui/wxpython/gui_core/forms.py: E722, F841
gui/wxpython/gui_core/ghelp.py: E722
gui/wxpython/gui_core/gselect.py: F841, E266, E722
gui/wxpython/gui_core/*: F841, E266, W605
gui/wxpython/gui_core/dialogs.py: F841, W605
gui/wxpython/gui_core/forms.py: F841
gui/wxpython/gui_core/gselect.py: F841, E266
gui/wxpython/gui_core/preferences.py: E266, F841
gui/wxpython/gui_core/treeview.py: F841
gui/wxpython/gui_core/widgets.py: F841, E722, E266
gui/wxpython/image2target/*: F841, E722, E265
gui/wxpython/gui_core/widgets.py: F841, E266
gui/wxpython/image2target/*: F841, E265
gui/wxpython/image2target/g.gui.image2target.py: E501, E265, F841
gui/wxpython/iscatt/*: F841, E722, E741, F405, F403
gui/wxpython/iscatt/*: F841, E741, F405, F403
gui/wxpython/lmgr/giface.py: E741
gui/wxpython/lmgr/frame.py: F841, E722, W605
gui/wxpython/lmgr/frame.py: F841, W605
# layertree still includes some formatting issues (it is ignored by Black)
gui/wxpython/lmgr/layertree.py: E722, E266, W504, E225
gui/wxpython/lmgr/layertree.py: E266, W504, E225
gui/wxpython/lmgr/workspace.py: F841
gui/wxpython/modules/*: F841, E722, W605
gui/wxpython/nviz/*: F841, E266, E722, W605, F403, F405
gui/wxpython/photo2image/*: F841, E722, E265
gui/wxpython/modules/*: F841, W605
gui/wxpython/nviz/*: F841, E266, W605, F403, F405
gui/wxpython/photo2image/*: F841, E265
gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841
gui/wxpython/psmap/*: F841, E266, E722, F405, F403
gui/wxpython/vdigit/*: F841, E722, E741, F405, F403
gui/wxpython/psmap/*: F841, E266, F405, F403
gui/wxpython/vdigit/*: F841, E741, F405, F403
gui/wxpython/vnet/*: F841
gui/wxpython/wxgui.py: F841
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/animation/mapwindow.py: F841
gui/wxpython/animation/provider.py: F841
gui/wxpython/tplot/frame.py: F841, E722, E741
gui/wxpython/tplot/frame.py: F841, E741
gui/wxpython/tplot/g.gui.tplot.py: E501
gui/wxpython/rdigit/g.gui.rdigit.py: F841
gui/wxpython/iclass/dialogs.py: E741
gui/wxpython/iclass/digit.py: F405, F403
gui/wxpython/iclass/frame.py: F405, F403
gui/wxpython/iclass/g.gui.iclass.py: E501
gui/wxpython/iclass/statistics.py: F841, F405, F403
gui/wxpython/wxplot/histogram.py: E722
gui/wxpython/wxplot/profile.py: F841, E722
gui/wxpython/wxplot/base.py: F841, E722
gui/wxpython/wxplot/profile.py: F841
gui/wxpython/wxplot/base.py: F841
gui/wxpython/location_wizard/dialogs.py: F841
gui/wxpython/location_wizard/wizard.py: E722
gui/wxpython/mapdisp/main.py: E722
gui/wxpython/mapdisp/test_mapdisp.py: E501
gui/wxpython/mapdisp/statusbar.py: F841
gui/wxpython/mapswipe/g.gui.mapswipe.py: E501
gui/wxpython/mapwin/base.py: E722
gui/wxpython/mapwin/buffered.py: E722
gui/wxpython/mapwin/graphics.py: E722
gui/wxpython/startup/locdownload.py: E722, E402
gui/wxpython/startup/locdownload.py: E402
gui/wxpython/timeline/g.gui.timeline.py: E501, E741
gui/wxpython/timeline/frame.py: E741
gui/wxpython/tools/build_modules_xml.py: E722
gui/wxpython/web_services/cap_interface.py: E501
gui/wxpython/web_services/widgets.py: F841, E741, W605, E402
gui/wxpython/rlisetup/frame.py: E741
gui/wxpython/rlisetup/sampling_frame.py: F841
gui/wxpython/rlisetup/wizard.py: E722, E741
gui/wxpython/rlisetup/wizard.py: E741
# Generated file
gui/wxpython/menustrings.py: E501
# F821 undefined name 'cmp'
Expand All @@ -142,18 +130,15 @@ per-file-ignores =
python/grass/pygrass/rpc/__init__.py: F401, F403
python/grass/pygrass/utils.py: E402
python/grass/script/task.py: W605
python/grass/temporal/abstract_space_time_dataset.py: W605, F841, E722
python/grass/temporal/c_libraries_interface.py: F841, E722
python/grass/temporal/core.py: E722
python/grass/temporal/datetime_math.py: F841, E722
python/grass/temporal/abstract_space_time_dataset.py: W605, F841
python/grass/temporal/c_libraries_interface.py: F841
python/grass/temporal/datetime_math.py: F841
python/grass/temporal/open_stds.py: F841
python/grass/temporal/spatial_topology_dataset_connector.py: E722
python/grass/temporal/temporal_algebra.py: E741, F841, E722
python/grass/temporal/temporal_granularity.py: F841, E722
python/grass/temporal/temporal_algebra.py: E741, F841
python/grass/temporal/temporal_granularity.py: F841
python/grass/temporal/temporal_raster_algebra.py: E741
python/grass/temporal/temporal_raster_base_algebra.py: F841, E722
python/grass/temporal/temporal_raster_base_algebra.py: F841
python/grass/temporal/temporal_raster3d_algebra.py: E741
python/grass/temporal/temporal_topology_dataset_connector.py: E722
python/grass/temporal/temporal_vector_algebra.py: E741, F841
python/grass/temporal/univar_statistics.py: E231
# Current benchmarks/tests are changing sys.path before import.
Expand All @@ -172,24 +157,19 @@ per-file-ignores =
python/grass/*/*/*/__init__.py: F401, F403
# E402 module level import not at top of file
scripts/d.polar/d.polar.py: F841
scripts/r.in.wms/wms_gdal_drv.py: F841, E722
scripts/r.in.wms/wms_gdal_drv.py: F841
scripts/r.in.wms/wms_cap_parsers.py: F841, E741
scripts/r.in.wms/wms_drv.py: E402, E722
scripts/r.in.wms/srs.py: E722
scripts/r.in.wms/wms_drv.py: E402
scripts/r.semantic.label/r.semantic.label.py: F841, E501
scripts/v.report/v.report.py: F841, E721
scripts/db.out.ogr/db.out.ogr.py: F841
scripts/g.extension/g.extension.py: F841, E722, E501
scripts/v.unpack/v.unpack.py: F841, E722, E501
scripts/v.import/v.import.py: F841, E722, E501
scripts/g.extension/g.extension.py: F841, E501
scripts/v.unpack/v.unpack.py: F841, E501
scripts/v.import/v.import.py: F841, E501
scripts/db.univar/db.univar.py: E741, E501
scripts/d.rast.leg/d.rast.leg.py: E741
scripts/d.frame/d.frame.py: E722
scripts/i.pansharpen/i.pansharpen.py: E722, E501
scripts/r.in.srtm/r.in.srtm.py: E722
scripts/r.fillnulls/r.fillnulls.py: E722
scripts/d.rast.edit/d.rast.edit.py: E722
scripts/v.what.strds/v.what.strds.py: E722, E501
scripts/i.pansharpen/i.pansharpen.py: E501
scripts/v.what.strds/v.what.strds.py: E501
# Line too long (esp. module interface definitions)
scripts/*/*.py: E501
# local variable 'column' is assigned to but never used
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def RunCmd(
if len(command) == 1 and not skipInterface:
try:
task = gtask.parse_interface(command[0])
except:
except Exception:
task = None
else:
task = None
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ def SetRegion(self, windres=False, windres3=False):

return grass_region

except:
except Exception:
return None

def GetListOfLayers(
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _generateLocale(self):
self.locs.sort()
# Add a default choice to not override system locale
self.locs.insert(0, "system")
except:
except Exception:
# No NLS
self.locs = ["system"]

Expand Down Expand Up @@ -992,7 +992,7 @@ def SaveToFile(self, settings=None):
if not os.path.exists(dirPath):
try:
os.mkdir(dirPath)
except:
except Exception:
GError(_("Unable to create settings directory"))
return
try:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/toolboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def getMenudataFile(userRootFile, newFile, fallback):
fh.write(xml)
fh.close()
return menudataFile
except:
except Exception:
_debug(
2,
(
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def GetTempfile(pref=None):
return os.path.join(pref, file)
else:
return tempfile
except:
except Exception:
return None


Expand Down Expand Up @@ -254,7 +254,7 @@ def ListOfCatsToRange(cats):

try:
cats = list(map(int, cats))
except:
except Exception:
return catstr

i = 0
Expand Down Expand Up @@ -579,7 +579,7 @@ def GetListOfLocations(dbase):
os.path.join(location, "*")
):
listOfLocations.append(os.path.basename(location))
except:
except Exception:
pass
except (UnicodeEncodeError, UnicodeDecodeError) as e:
raise e
Expand Down Expand Up @@ -634,7 +634,7 @@ def _getGDALFormats():
"""Get dictionary of available GDAL drivers"""
try:
ret = grass.read_command("r.in.gdal", quiet=True, flags="f")
except:
except Exception:
ret = None

return _parseFormats(ret), _parseFormats(ret, writableOnly=True)
Expand All @@ -644,7 +644,7 @@ def _getOGRFormats():
"""Get dictionary of available OGR drivers"""
try:
ret = grass.read_command("v.in.ogr", quiet=True, flags="f")
except:
except Exception:
ret = None

return _parseFormats(ret), _parseFormats(ret, writableOnly=True)
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __processFile(self):
try:
self.layerManager["pos"] = (posVal[0], posVal[1])
self.layerManager["size"] = (posVal[2], posVal[3])
except:
except Exception:
pass
# current working directory
cwdPath = self.__getNodeText(node_lm, "cwd")
Expand Down Expand Up @@ -157,7 +157,7 @@ def __processFile(self):
try:
pos = (posVal[0], posVal[1])
size = (posVal[2], posVal[3])
except:
except Exception:
pos = None
size = None
# this happens on Windows when mapwindow is minimized when
Expand Down Expand Up @@ -2023,7 +2023,7 @@ def _get_value(self, line):
"""Get value of element"""
try:
return line.strip(" ").split(" ")[1].strip(" ")
except:
except Exception:
return ""

def _get_element(self, line):
Expand Down
14 changes: 7 additions & 7 deletions gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None):
try:
# for maps connected via v.external
keyId = columns.index(keyColumn)
except:
except Exception:
keyId = -1

# read data
Expand Down Expand Up @@ -963,7 +963,7 @@ def OnLayerPageChanged(self, event):
self.layerPage[self.selLayer]["data"]
).GetItemCount()
)
except:
except Exception:
pass

if idCol:
Expand Down Expand Up @@ -1645,7 +1645,7 @@ def OnDataItemAdd(self, event):
if dlg.ShowModal() == wx.ID_OK:
try: # get category number
cat = int(dlg.GetValues(columns=[keyColumn])[0])
except:
except Exception:
cat = -1

try:
Expand Down Expand Up @@ -1678,7 +1678,7 @@ def OnDataItemAdd(self, event):
values[i] = int(float(values[i]))
elif tlist.columns[columnName[i]]["ctype"] == float:
values[i] = float(values[i])
except:
except Exception:
raise ValueError(
_("Value '%(value)s' needs to be entered as %(type)s.")
% {
Expand Down Expand Up @@ -3818,7 +3818,7 @@ def OnDeleteLayer(self, event):
"""Delete layer"""
try:
layer = int(self.deleteLayer.GetValue())
except:
except Exception:
return

RunCommand(
Expand Down Expand Up @@ -3865,10 +3865,10 @@ def OnChangeLayer(self, event):
"""Layer number of layer to be deleted is changed"""
try:
layer = int(event.GetString())
except:
except Exception:
try:
layer = self.mapDBInfo.layers.keys()[0]
except:
except Exception:
return

if self.GetCurrentPage() == self.modifyPanel:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def GetSQLString(self, updateValues=False):
id = columns[name]["ids"][idx]
try:
newvalue = self.FindWindowById(id).GetValue()
except:
except Exception:
newvalue = self.FindWindowById(id).GetLabel()

if newvalue:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
self.parent = parent
try:
mapdisplay = self.parent.GetMapDisplay()
except:
except Exception:
mapdisplay = None

DbMgrBase.__init__(
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/sqlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def OnUniqueValues(self, event, justsample=False):
try:
idx = self.list_columns.GetSelections()[0]
column = self.list_columns.GetString(idx)
except:
except Exception:
self.list_values.Clear()
return

Expand Down
Loading

0 comments on commit 2b60b99

Please sign in to comment.