Skip to content

Commit

Permalink
scripts: Remove unused vars or ignore in Flake8 (#1498)
Browse files Browse the repository at this point in the history
* Remove unused variables.
* Use one previously unused exception for an error message.
* Ignore the unclear cases using per-file-ignores (to be resolved in the future).
  • Loading branch information
wenzeslaus committed Apr 6, 2021
1 parent d2dd0dd commit d7a56b3
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 18 deletions.
14 changes: 13 additions & 1 deletion scripts/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ ignore =
E402, # module level import not at top of file
E722, # do not use bare 'except'
E741, # ambiguous variable name 'l'
F841, # local variable 'center' is assigned to but never used
E501, # line too long (161 > 150 characters)

per-file-ignores =
# Many of these ignores can and should be removed and the problem fixed.
# F841 local variable is assigned to but never used
d.polar/d.polar.py: F841
r.in.wms/wms_gdal_drv.py: F841
r.in.wms/wms_cap_parsers.py: F841
i.band/i.band.py: F841
v.report/v.report.py: F841
db.out.ogr/db.out.ogr.py: F841
g.extension/g.extension.py: F841
v.unpack/v.unpack.py: F841
v.import/v.import.py: F841

max-line-length = 88
exclude =
.git,
Expand Down
2 changes: 1 addition & 1 deletion scripts/d.rast.edit/d.rast.edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def __init__(self, app):
sizer = wx.BoxSizer(orient=wx.VERTICAL)

self.canvas = Canvas(app, parent=self)
si = sizer.Add(self.canvas, proportion=1, flag=wx.EXPAND)
sizer.Add(self.canvas, proportion=1, flag=wx.EXPAND)

tools = wx.BoxSizer(wx.HORIZONTAL)

Expand Down
1 change: 0 additions & 1 deletion scripts/g.bands/g.bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
def main():
from grass.bandref import BandReferenceReader, BandReferenceReaderError

band = None
kwargs = {}
if "," in options["pattern"]:
gs.fatal("Multiple values not supported")
Expand Down
8 changes: 6 additions & 2 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,12 @@ def install_module_xml(mlist):
desc = gtask.parse_interface(name).description
# mname = gtask.parse_interface(name).name
keywords = gtask.parse_interface(name).keywords
except Exception as e:
grass.warning(_("No metadata available for module '%s'.") % name)
except Exception as error:
grass.warning(
_("No metadata available for module '{name}': {error}").format(
name=name, error=error
)
)
continue

tnode = None
Expand Down
1 change: 0 additions & 1 deletion scripts/i.pansharpen/i.pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def pca(pan, ms1, ms2, ms3, out, pid, sproc):
b3evect.append(float(l.split(",")[3]))

# inverse PCA with hi res pan channel substituted for principal component 1
pca1 = "tmp%s.pca.1" % pid
pca2 = "tmp%s.pca.2" % pid
pca3 = "tmp%s.pca.3" % pid
b1evect1 = b1evect[0]
Expand Down
4 changes: 2 additions & 2 deletions scripts/r.fillnulls/r.fillnulls.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def main():
)
% (input,)
)
except CalledModuleError as e:
except CalledModuleError:
grass.fatal(
_("Failure during bspline interpolation. Error message: %s")
% stderr
Expand Down Expand Up @@ -643,7 +643,7 @@ def main():
)
% (input,)
)
except CalledModuleError as e:
except CalledModuleError:
grass.fatal(
_("Failure during bspline interpolation. Error message: %s")
% stderr
Expand Down
2 changes: 1 addition & 1 deletion scripts/r.import/r.import.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def main():
% GDALdatasource
)
return 0
except CalledModuleError as e:
except CalledModuleError:
grass.fatal(_("Unable to import GDAL dataset <%s>") % GDALdatasource)

grassenv = grass.gisenv()
Expand Down
1 change: 0 additions & 1 deletion scripts/r.in.wms/wms_drv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,6 @@ def _parseTilePattern(self, group_t_patts, bbox, region):
if best_patt is None:
best_res = t_res[comp_res]
best_patt = pattern
first = False
continue

best_diff = best_res - res[comp_res]
Expand Down
4 changes: 0 additions & 4 deletions scripts/v.dissolve/v.dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ def main():
if coltype["type"] not in ("INTEGER", "SMALLINT", "CHARACTER", "TEXT"):
grass.fatal(_("Key column must be of type integer or string"))

f = grass.vector_layer_db(input, layer)

table = f["table"]

tmpfile = "%s_%s" % (output, tmp)

try:
Expand Down
2 changes: 0 additions & 2 deletions scripts/v.in.lines/v.in.lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ def main():
fs = separator(options["separator"])
threeD = flags["z"]

prog = "v.in.lines"

if threeD:
do3D = "z"
else:
Expand Down
2 changes: 0 additions & 2 deletions scripts/v.in.mapgen/v.in.mapgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ def main():

prog = "v.in.mapgen"

opts = ""

if not os.path.isfile(infile):
grass.fatal(_("Input file <%s> not found") % infile)

Expand Down

0 comments on commit d7a56b3

Please sign in to comment.