浏览代码

Reduce usage of bare except (#1608)

* Replaces bare except by Exception in r.plane, v.in.wfs, v.to.lines.py, g.manual (good enough for Flake8).
* Removes the per-file ignores from the .flake8 file.
ShubhamSwati 3 年之前
父节点
当前提交
8ed47e4b76
共有 5 个文件被更改,包括 4 次插入8 次删除
  1. 0 4
      scripts/.flake8
  2. 1 1
      scripts/g.manual/g.manual.py
  3. 1 1
      scripts/r.plane/r.plane.py
  4. 1 1
      scripts/v.in.wfs/v.in.wfs.py
  5. 1 1
      scripts/v.to.lines/v.to.lines.py

+ 0 - 4
scripts/.flake8

@@ -29,10 +29,6 @@ per-file-ignores =
     r.in.srtm/r.in.srtm.py: E722
     r.fillnulls/r.fillnulls.py: E722
     d.rast.edit/d.rast.edit.py: E722
-    g.manual/g.manual.py: E722
-    v.to.lines/v.to.lines.py: E722
-    v.in.wfs/v.in.wfs.py: E722
-    r.plane/r.plane.py: E722
     v.what.strds/v.what.strds.py: E722
     i.in.spotvgt/i.in.spotvgt.py: E722
 

+ 1 - 1
scripts/g.manual/g.manual.py

@@ -104,7 +104,7 @@ def start_browser(entry):
 
     try:
         webbrowser.open(url_path)
-    except:
+    except Exception:
         grass.fatal(
             _("Error starting browser '%(browser)s' for HTML file" " '%(path)s'")
             % dict(browser=browser, path=path)

+ 1 - 1
scripts/r.plane/r.plane.py

@@ -80,7 +80,7 @@ def main():
         try:
             ea = float(gscript.utils.float_or_dms(options["easting"]))
             no = float(gscript.utils.float_or_dms(options["northing"]))
-        except:
+        except Exception:
             gscript.fatal(_("Input coordinates seems to be invalid"))
     el = float(options["elevation"])
 

+ 1 - 1
scripts/v.in.wfs/v.in.wfs.py

@@ -204,7 +204,7 @@ def main():
     try:
         grass.run_command("v.in.ogr", flags="o", input=tmpxml, output=out)
         grass.message(_("Vector map <%s> imported from WFS.") % out)
-    except:
+    except Exception:
         grass.message(_("WFS import failed"))
     finally:
         try_remove(tmpxml)

+ 1 - 1
scripts/v.to.lines/v.to.lines.py

@@ -188,7 +188,7 @@ def main():
             )
             grass.fatal(_("Error removing table from layer 1"))
     # TODO: when this except is happaning, it seems that never, so it seems wrong
-    except:
+    except Exception:
         grass.warning(_("No table for layer %d" % 1))
     try:
         grass.run_command(