Skip to content

Commit

Permalink
style: Fix repeated-append (FURB113) (#4014)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Jul 10, 2024
1 parent 2186ec5 commit d41987c
Show file tree
Hide file tree
Showing 26 changed files with 209 additions and 162 deletions.
17 changes: 9 additions & 8 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,14 +1221,15 @@ def GetDisplayVectSettings():
else:
settings.append("fcolor=none")

settings.append(
"width=%s" % UserSettings.Get(group="vectorLayer", key="line", subkey="width")
)
settings.append(
"icon=%s" % UserSettings.Get(group="vectorLayer", key="point", subkey="symbol")
)
settings.append(
"size=%s" % UserSettings.Get(group="vectorLayer", key="point", subkey="size")
settings.extend(
(
"width=%s"
% UserSettings.Get(group="vectorLayer", key="line", subkey="width"),
"icon=%s"
% UserSettings.Get(group="vectorLayer", key="point", subkey="symbol"),
"size=%s"
% UserSettings.Get(group="vectorLayer", key="point", subkey="size"),
)
)
types = []
for ftype in ["point", "line", "boundary", "centroid", "area", "face"]:
Expand Down
36 changes: 22 additions & 14 deletions gui/wxpython/datacatalog/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,17 @@ def _estimateResampling(self):
def OnReproject(self, event):
cmd = []
if self.etype == "raster":
cmd.append("r.proj")
cmd.append("dbase=" + self.iGisdbase)
cmd.append("project=" + self.iLocation)
cmd.append("mapset=" + self.iMapset)
cmd.append("input=" + self.iLayer)
cmd.append("output=" + self.oLayer)
cmd.append("method=" + self.resampling.GetStringSelection())
cmd.extend(
(
"r.proj",
"dbase=" + self.iGisdbase,
"project=" + self.iLocation,
"mapset=" + self.iMapset,
"input=" + self.iLayer,
"output=" + self.oLayer,
"method=" + self.resampling.GetStringSelection(),
)
)

self.oEnv["GRASS_REGION"] = region_env(
n=self.params["n"],
Expand All @@ -228,13 +232,17 @@ def OnReproject(self, event):
env=self.oEnv,
)
else:
cmd.append("v.proj")
cmd.append("dbase=" + self.iGisdbase)
cmd.append("project=" + self.iLocation)
cmd.append("mapset=" + self.iMapset)
cmd.append("input=" + self.iLayer)
cmd.append("output=" + self.oLayer)
cmd.append("smax=" + self.vsplit.GetValue())
cmd.extend(
(
"v.proj",
"dbase=" + self.iGisdbase,
"project=" + self.iLocation,
"mapset=" + self.iMapset,
"input=" + self.iLayer,
"output=" + self.oLayer,
"smax=" + self.vsplit.GetValue(),
)
)

self._giface.RunCmd(
cmd,
Expand Down
12 changes: 8 additions & 4 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2909,10 +2909,14 @@ def GetValues(self, columns=None):
except ValueError:
return valuelist

valuelist.append(self.xcoord.GetValue())
valuelist.append(self.ycoord.GetValue())
valuelist.append(self.ecoord.GetValue())
valuelist.append(self.ncoord.GetValue())
valuelist.extend(
(
self.xcoord.GetValue(),
self.ycoord.GetValue(),
self.ecoord.GetValue(),
self.ncoord.GetValue(),
)
)

return valuelist

Expand Down
10 changes: 7 additions & 3 deletions gui/wxpython/gui_core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ def ShowContextMenu(self, node):
col1 = "\n".join([val[1] for val in values if val[1]])
col2 = "\n".join([val[0] for val in values if val[0]])
table = "\n".join([val[0] + ": " + val[1] for val in values])
texts.append((_("Copy from '%s' column") % self._colNames[1], col1))
texts.append((_("Copy from '%s' column") % self._colNames[0], col2))
texts.append((_("Copy selected lines"), table))
texts.extend(
(
(_("Copy from '%s' column") % self._colNames[1], col1),
(_("Copy from '%s' column") % self._colNames[0], col2),
(_("Copy selected lines"), table),
)
)
else:
label1 = nodes[0].label
texts.append((_("Copy '%s'" % self._cutLabel(label1)), label1))
Expand Down
16 changes: 10 additions & 6 deletions gui/wxpython/image2target/ii2t_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2855,12 +2855,16 @@ def GetValues(self, columns=None):
except ValueError:
return valuelist

valuelist.append(self.xcoord.GetValue())
valuelist.append(self.ycoord.GetValue())
valuelist.append(self.zcoord.GetValue())
valuelist.append(self.ecoord.GetValue())
valuelist.append(self.ncoord.GetValue())
valuelist.append(self.hcoord.GetValue())
valuelist.extend(
(
self.xcoord.GetValue(),
self.ycoord.GetValue(),
self.zcoord.GetValue(),
self.ecoord.GetValue(),
self.ncoord.GetValue(),
self.hcoord.GetValue(),
)
)

return valuelist

Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ def Plot(self, cats_order, scatts, ellipses, styles):
aspect="equal",
)

callafter_list.append([self.axes.draw_artist, [img]])
callafter_list.append([gs.try_remove, [merged_img.filename]])
callafter_list.extend(
([self.axes.draw_artist, [img]], [gs.try_remove, [merged_img.filename]])
)

for cat_id in cats_order:
if cat_id == 0:
Expand Down
14 changes: 9 additions & 5 deletions gui/wxpython/mapwin/buffered.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,15 @@ def DrawCompRegionExtent(self):
reg = dispReg if utils.isInRegion(dispReg, compReg) else compReg

regionCoords = []
regionCoords.append((reg["w"], reg["n"]))
regionCoords.append((reg["e"], reg["n"]))
regionCoords.append((reg["e"], reg["s"]))
regionCoords.append((reg["w"], reg["s"]))
regionCoords.append((reg["w"], reg["n"]))
regionCoords.extend(
(
(reg["w"], reg["n"]),
(reg["e"], reg["n"]),
(reg["e"], reg["s"]),
(reg["w"], reg["s"]),
(reg["w"], reg["n"]),
)
)

# draw region extent
self.polypen = wx.Pen(
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def __init__(
task = gtask.parse_interface("g.extension")
ignoreFlags = ["l", "c", "g", "a", "f", "t", "help", "quiet"]
if sys.platform == "win32":
ignoreFlags.append("d")
ignoreFlags.append("i")
ignoreFlags.extend(("d", "i"))

for f in task.get_options()["flags"]:
name = f.get("name", "")
Expand Down
12 changes: 8 additions & 4 deletions gui/wxpython/photo2image/ip2i_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,10 +1977,14 @@ def GetValues(self, columns=None):
except ValueError:
return valuelist

valuelist.append(self.xcoord.GetValue())
valuelist.append(self.ycoord.GetValue())
valuelist.append(self.ecoord.GetValue())
valuelist.append(self.ncoord.GetValue())
valuelist.extend(
(
self.xcoord.GetValue(),
self.ycoord.GetValue(),
self.ecoord.GetValue(),
self.ncoord.GetValue(),
)
)

return valuelist

Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ def PSFile(self, filename=None, pdf=False):
cmd.append("-e")
if self.instruction[self.pageId]["Orientation"] == "Landscape":
cmd.append("-r")
cmd.append("input=%s" % instrFile)
cmd.append("output=%s" % filename)
cmd.extend(("input=%s" % instrFile, "output=%s" % filename))
if pdf:
self.SetStatusText(_("Generating PDF..."), 0)
elif not temp:
Expand Down
12 changes: 8 additions & 4 deletions gui/wxpython/timeline/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,14 @@ def InfoFormat(timeData, datasetName, mapIndex):
elif etype == "str3ds":
text.append(_("Space time 3D raster dataset: %s") % name)

text.append(_("Mapset: %s") % mapset)
text.append(_("Map name: %s") % timeData[datasetName]["names"][mapIndex])
text.append(_("Start time: %s") % timeData[datasetName]["start_datetime"][mapIndex])
text.append(_("End time: %s") % timeData[datasetName]["end_datetime"][mapIndex])
text.extend(
(
_("Mapset: %s") % mapset,
_("Map name: %s") % timeData[datasetName]["names"][mapIndex],
_("Start time: %s") % timeData[datasetName]["start_datetime"][mapIndex],
_("End time: %s") % timeData[datasetName]["end_datetime"][mapIndex],
)
)

if not timeData[datasetName]["validTopology"]:
text.append(_("WARNING: invalid topology"))
Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/tplot/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,9 @@ def InfoFormat(timeData, values):
elif etype == "str3ds":
text.append(_("Space time 3D raster dataset: %s") % key)

text.append(_("Value for {date} is {val}".format(date=val[0], val=val[1])))
text.append("\n")
text.extend(
(_("Value for {date} is {val}".format(date=val[0], val=val[1])), "\n")
)
text.append(_("Press Del to dismiss."))

return "\n".join(text)
Expand Down
8 changes: 6 additions & 2 deletions gui/wxpython/vnet/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,12 @@ def OnPageChanged(self, event):
"""Tab switched"""
if event.GetEventObject() == self.notebook:
dbMgrIndxs = []
dbMgrIndxs.append(self.notebook.GetPageIndexByName("inputDbMgr"))
dbMgrIndxs.append(self.notebook.GetPageIndexByName("resultDbMgr"))
dbMgrIndxs.extend(
(
self.notebook.GetPageIndexByName("inputDbMgr"),
self.notebook.GetPageIndexByName("resultDbMgr"),
)
)
if self.notebook.GetSelection() in dbMgrIndxs:
self.stBar.AddStatusItem(
text=_("Loading tables..."),
Expand Down
17 changes: 10 additions & 7 deletions gui/wxpython/vnet/vnet_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,13 @@ def _vnetPathRunAn(self, analysis, output, params, flags, catPts):
else:
cmdParams.append("input=" + params["input"])

cmdParams.append("file=" + self.coordsTmpFile)

cmdParams.append("dmax=" + str(params["max_dist"]))

cmdParams.append("--overwrite")
cmdParams.extend(
(
"file=" + self.coordsTmpFile,
"dmax=" + str(params["max_dist"]),
"--overwrite",
)
)
self._prepareCmd(cmd=cmdParams)

if flags["t"]:
Expand Down Expand Up @@ -697,8 +699,9 @@ def _runAn(self, analysis, output, params, flags, catPts):
if not self.tmpInPtsConnected:
return False

cmdParams.append("input=" + self.tmpInPtsConnected.GetVectMapName())
cmdParams.append("--overwrite")
cmdParams.extend(
("input=" + self.tmpInPtsConnected.GetVectMapName(), "--overwrite")
)

self._setCmdForSpecificAn(cmdParams)

Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/vnet/vnet_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@ def GetColumns(self, only_relevant=True):
cols_data = deepcopy(self.cols)

hidden_cols = []
hidden_cols.append(self.cols["name"].index("e"))
hidden_cols.append(self.cols["name"].index("n"))
hidden_cols.extend((self.cols["name"].index("e"), self.cols["name"].index("n")))

analysis, valid = self.an_params.GetParam("analysis")
if only_relevant and len(self.an_data[analysis]["cmdParams"]["cats"]) <= 1:
Expand Down
20 changes: 10 additions & 10 deletions man/parser_standard_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,22 @@ def html(self, endline="\n", indent=" ", toptions="border=1"):
"""Return a HTML table with the options"""
html = ["<table{0}>".format(" " + toptions if toptions else "")]
# write headers
html.append(indent + "<thead>")
html.append(indent + "<tr>")
html.append(indent * 2 + "<th>{0}</th>".format("option"))
html.extend(
(
indent + "<thead>",
indent + "<tr>",
indent * 2 + "<th>{0}</th>".format("option"),
)
)
for col in self.columns:
html.append(indent * 2 + "<th>{0}</th>".format(col))
html.append(indent + "</tr>")
html.append(indent + "</thead>")
html.append(indent + "<tbody>")
html.extend((indent + "</tr>", indent + "</thead>", indent + "<tbody>"))
for optname, options in self.options:
html.append(indent + "<tr>")
html.append(indent * 2 + "<td>{0}</td>".format(optname))
html.extend((indent + "<tr>", indent * 2 + "<td>{0}</td>".format(optname)))
for col in self.columns:
html.append(indent * 2 + "<td>{0}</td>".format(options.get(col, "")))
html.append(indent + "</tr>")
html.append(indent + "</tbody>")
html.append("</table>")
html.extend((indent + "</tbody>", "</table>"))
return endline.join(html)

def _repr_html_(self):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ ignore = [
"FURB103", # write-whole-file.
"FURB105", # print-empty-string
"FURB110", # if-exp-instead-of-or-operator
"FURB113", # repeated-append
"FURB116", # f-string-number-format
"FURB116", # f-string-number-format
"FURB118", # reimplemented-operator
Expand Down
44 changes: 22 additions & 22 deletions python/grass/gunittest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,28 +269,28 @@ def stopTestRun(self):
# write test details and just write status=failed
if not run:
run = errored + failed + succeeded
infos.append("total=%d" % (run))

infos.append("failures=%d" % failed)
infos.append("errors=%d" % errored)
infos.append("successes=%d" % succeeded)
infos.append("skipped=%d" % skipped)

# TODO: document this: if not supported by view,
# expected_failures should be counted as failures and vice versa
# or both add to skipped as unclear?
infos.append("expected_failures=%d" % expectedFails)
infos.append("unexpected_successes=%d" % unexpectedSuccesses)

# TODO: include each module just once? list good and bad modules?
infos.append("tested_modules=%s" % ",".join(self._grass_modules))
infos.append("supplementary_files=%s" % ",".join(self._supplementary_files))

# module, modules?, c, c++?, python
# TODO: include also type modules?
# TODO: include also C++ code?
# TODO: distinguish C and Python modules?
infos.append("test_type=%s" % (self.test_type))
infos.extend(
(
"total=%d" % (run),
"failures=%d" % failed,
"errors=%d" % errored,
"successes=%d" % succeeded,
"skipped=%d" % skipped,
# TODO: document this: if not supported by view,
# expected_failures should be counted as failures and vice versa
# or both add to skipped as unclear?
"expected_failures=%d" % expectedFails,
"unexpected_successes=%d" % unexpectedSuccesses,
# TODO: include each module just once? list good and bad modules?
"tested_modules=%s" % ",".join(self._grass_modules),
"supplementary_files=%s" % ",".join(self._supplementary_files),
# module, modules?, c, c++?, python
# TODO: include also type modules?
# TODO: include also C++ code?
# TODO: distinguish C and Python modules?
"test_type=%s" % (self.test_type),
)
)

self._stream.write("\n".join(infos))
self._stream.write("\n")
Expand Down
Loading

0 comments on commit d41987c

Please sign in to comment.