From e411ade9e6deee70506f9375334fa4f75d78387a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:34:57 +0000 Subject: [PATCH 1/3] style: Fix superfluous-else-break (RET508) Ruff rule: https://docs.astral.sh/ruff/rules/superfluous-else-break/ --- doc/python/m.distance.py | 3 +-- gui/wxpython/gui_core/widgets.py | 2 +- gui/wxpython/iclass/dialogs.py | 5 ++--- gui/wxpython/iscatt/frame.py | 5 ++--- gui/wxpython/psmap/instructions.py | 2 +- gui/wxpython/vnet/dialogs.py | 5 ++--- gui/wxpython/vnet/vnet_data.py | 2 +- pyproject.toml | 1 - python/grass/temporal/temporal_algebra.py | 6 +----- python/grass/temporal/temporal_raster_base_algebra.py | 2 +- python/grass/temporal/temporal_vector_algebra.py | 2 +- scripts/db.in.ogr/db.in.ogr.py | 3 +-- scripts/v.what.strds/v.what.strds.py | 3 +-- temporal/t.vect.observe.strds/t.vect.observe.strds.py | 3 +-- 14 files changed, 16 insertions(+), 28 deletions(-) diff --git a/doc/python/m.distance.py b/doc/python/m.distance.py index 576760c3b40..2383cbfb669 100755 --- a/doc/python/m.distance.py +++ b/doc/python/m.distance.py @@ -82,8 +82,7 @@ def main(): line = sys.stdin.readline().strip() if not line: # EOF break - else: - coords.append(line.split(",")) + coords.append(line.split(",")) else: # read from coord= command line option p = None diff --git a/gui/wxpython/gui_core/widgets.py b/gui/wxpython/gui_core/widgets.py index 87a09a590d8..b787bf23037 100644 --- a/gui/wxpython/gui_core/widgets.py +++ b/gui/wxpython/gui_core/widgets.py @@ -1603,7 +1603,7 @@ def _loadSettings_v2(self, fd_lines): idx = line.find(";", i_last) if idx < 0: break - elif idx != 0: + if idx != 0: # find out whether it is separator # $$$$; - it is separator # $$$$$; - it is not separator diff --git a/gui/wxpython/iclass/dialogs.py b/gui/wxpython/iclass/dialogs.py index 322bfcf5721..55128a8c0b1 100644 --- a/gui/wxpython/iclass/dialogs.py +++ b/gui/wxpython/iclass/dialogs.py @@ -486,9 +486,8 @@ def GetSelectedIndices(self, state=wx.LIST_STATE_SELECTED): index = self.GetNextItem(lastFound, wx.LIST_NEXT_ALL, state) if index == -1: break - else: - lastFound = index - indices.append(index) + lastFound = index + indices.append(index) return indices def OnEdit(self, event): diff --git a/gui/wxpython/iscatt/frame.py b/gui/wxpython/iscatt/frame.py index 122aa053b9b..f536563b5de 100644 --- a/gui/wxpython/iscatt/frame.py +++ b/gui/wxpython/iscatt/frame.py @@ -501,9 +501,8 @@ def GetSelectedIndices(self, state=wx.LIST_STATE_SELECTED): index = self.GetNextItem(lastFound, wx.LIST_NEXT_ALL, state) if index == -1: break - else: - lastFound = index - indices.append(index) + lastFound = index + indices.append(index) return indices def DeselectAll(self): diff --git a/gui/wxpython/psmap/instructions.py b/gui/wxpython/psmap/instructions.py index 845e99b2e6a..2e558949023 100644 --- a/gui/wxpython/psmap/instructions.py +++ b/gui/wxpython/psmap/instructions.py @@ -698,7 +698,7 @@ def Read(self, instruction, text, **kwargs): if line.split()[1].lower() in {"n", "no", "none"}: instr["border"] = "n" break - elif line.split()[1].lower() in {"y", "yes"}: + if line.split()[1].lower() in {"y", "yes"}: instr["border"] = "y" elif line.startswith("width"): instr["width"] = line.split()[1] diff --git a/gui/wxpython/vnet/dialogs.py b/gui/wxpython/vnet/dialogs.py index ee553a0b741..242c1a5b9b4 100644 --- a/gui/wxpython/vnet/dialogs.py +++ b/gui/wxpython/vnet/dialogs.py @@ -1980,7 +1980,6 @@ def GetSelectedIndices(self, state=wx.LIST_STATE_SELECTED): index = self.GetNextItem(lastFound, wx.LIST_NEXT_ALL, state) if index == -1: break - else: - lastFound = index - indices.append(index) + lastFound = index + indices.append(index) return indices diff --git a/gui/wxpython/vnet/vnet_data.py b/gui/wxpython/vnet/vnet_data.py index f2f17b0bfb5..ee6159eb403 100644 --- a/gui/wxpython/vnet/vnet_data.py +++ b/gui/wxpython/vnet/vnet_data.py @@ -1297,7 +1297,7 @@ def _getHistStepData(self, histStep): for line in hist: if not line.strip() and isSearchedHistStep: break - elif not line.strip(): + if not line.strip(): newHistStep = True continue elif isSearchedHistStep: diff --git a/pyproject.toml b/pyproject.toml index 4b7856bab3b..9c358cc0c93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,6 @@ ignore = [ "RET503", # implicit-return "RET506", # superfluous-else-raise "RET507", # superfluous-else-continue - "RET508", # superfluous-else-break "RUF003", # ambiguous-unicode-character-comment "RUF005", # collection-literal-concatenation "RUF012", # mutable-class-default diff --git a/python/grass/temporal/temporal_algebra.py b/python/grass/temporal/temporal_algebra.py index e4717eb3326..b143488c863 100644 --- a/python/grass/temporal/temporal_algebra.py +++ b/python/grass/temporal/temporal_algebra.py @@ -1159,11 +1159,7 @@ def set_temporal_extent_list(self, maplist, topolist=["EQUAL"], temporal="l"): if returncode == 0: break # Append map to result map list. - elif returncode == 1: - # print(map_new.get_id() + " " + - # str(map_new.get_temporal_extent_as_tuple())) - # print(map_new.condition_value) - # print(map_new.cmd_list) + if returncode == 1: # resultlist.append(map_new) resultdict[map_new.get_id()] = map_new diff --git a/python/grass/temporal/temporal_raster_base_algebra.py b/python/grass/temporal/temporal_raster_base_algebra.py index 8ff156cbed5..ef720b52c4e 100644 --- a/python/grass/temporal/temporal_raster_base_algebra.py +++ b/python/grass/temporal/temporal_raster_base_algebra.py @@ -610,7 +610,7 @@ def set_temporal_extent_list( if returncode == 0: break # Append map to result map list. - elif returncode == 1: + if returncode == 1: # print(map_new.cmd_list) # resultlist.append(map_new) if cmd_bool: diff --git a/python/grass/temporal/temporal_vector_algebra.py b/python/grass/temporal/temporal_vector_algebra.py index 551c69783f5..2f28da0c7e5 100644 --- a/python/grass/temporal/temporal_vector_algebra.py +++ b/python/grass/temporal/temporal_vector_algebra.py @@ -386,7 +386,7 @@ def set_temporal_extent_list(self, maplist, topolist=["EQUAL"], temporal="l"): if returncode == 0: break # Append map to result map list. - elif returncode == 1: + if returncode == 1: # resultlist.append(map_new) resultdict[map_new.get_id()] = map_new if returncode == 0: diff --git a/scripts/db.in.ogr/db.in.ogr.py b/scripts/db.in.ogr/db.in.ogr.py index a95919f4936..b7d7b01b51e 100755 --- a/scripts/db.in.ogr/db.in.ogr.py +++ b/scripts/db.in.ogr/db.in.ogr.py @@ -115,8 +115,7 @@ def main(): "db.execute", input="-", stdin="DROP TABLE %s" % output ) break - else: - gs.fatal(_("Table <%s> already exists") % output) + gs.fatal(_("Table <%s> already exists") % output) # treat DB as real vector map... layer = db_table or None diff --git a/scripts/v.what.strds/v.what.strds.py b/scripts/v.what.strds/v.what.strds.py index 8be00f3536d..2c819fd0e44 100644 --- a/scripts/v.what.strds/v.what.strds.py +++ b/scripts/v.what.strds/v.what.strds.py @@ -202,8 +202,7 @@ def main(): if name is None: isvalid = False break - else: - mapname_list.append(name) + mapname_list.append(name) if isvalid: entry = mapmatrizes[0][i] diff --git a/temporal/t.vect.observe.strds/t.vect.observe.strds.py b/temporal/t.vect.observe.strds/t.vect.observe.strds.py index 547f60a3250..7e9ac225890 100755 --- a/temporal/t.vect.observe.strds/t.vect.observe.strds.py +++ b/temporal/t.vect.observe.strds/t.vect.observe.strds.py @@ -185,8 +185,7 @@ def main(): if name is None: isvalid = False break - else: - mapname_list.append(name) + mapname_list.append(name) if isvalid: entry = mapmatrizes[0][i] From d68c09cb4d3232a1a4a1416fb6c2c7321d0bf417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:46:19 +0000 Subject: [PATCH 2/3] style: Fix superfluous-else-raise (RET506) Ruff rule: https://docs.astral.sh/ruff/rules/superfluous-else-raise/ --- gui/wxpython/core/gcmd.py | 7 +- gui/wxpython/dbmgr/base.py | 4 +- gui/wxpython/mapdisp/statusbar.py | 197 +++++++------ gui/wxpython/timeline/frame.py | 2 +- gui/wxpython/tplot/frame.py | 2 +- pyproject.toml | 1 - python/grass/imaging/images2avi.py | 31 +-- python/grass/pygrass/gis/__init__.py | 2 +- python/grass/pygrass/messages/__init__.py | 3 +- .../pygrass/modules/interface/parameter.py | 10 +- python/grass/pygrass/raster/category.py | 2 +- python/grass/pygrass/vector/table.py | 3 +- python/grass/script/task.py | 3 +- python/grass/temporal/temporal_algebra.py | 76 +++-- python/grass/temporal/temporal_operator.py | 260 +++++++++--------- .../temporal/temporal_raster_base_algebra.py | 11 +- scripts/r.in.wms/wms_cap_parsers.py | 3 +- 17 files changed, 301 insertions(+), 316 deletions(-) diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index a173e28c7f8..b22f0bc915d 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -311,9 +311,8 @@ def recv_some(p, t=0.1, e=1, tr=5, stderr=0): if r is None: if e: raise Exception(message) - else: - break - elif r: + break + if r: y.append(decode(r)) else: time.sleep(max((x - time.time()) / tr, 0)) @@ -415,7 +414,7 @@ def __init__( _("Error: ") + self.__GetError(), ) ) - elif rerr == sys.stderr: # redirect message to sys + if rerr == sys.stderr: # redirect message to sys stderr.write("Execution failed: '%s'" % (" ".join(self.cmd))) stderr.write( "%sDetails:%s%s" diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 1af8d6fccb1..668b16d394c 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -1662,8 +1662,8 @@ def OnDataItemAdd(self, event): raise ValueError( _("Category number (column %s) is missing.") % keyColumn ) - else: - continue + + continue try: if tlist.columns[columnName[i]]["ctype"] == int: diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index 4fea1ffcc81..8cf5c3b6ff7 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -542,23 +542,22 @@ def ReprojectENToMap(self, e, n, useDefinedProjection): ) if not settings: raise SbException(_("Projection not defined (check the settings)")) + # reproject values + projIn = settings + projOut = RunCommand("g.proj", flags="jf", read=True) + proj = projIn.split(" ")[0].split("=")[1] + if proj in {"ll", "latlong", "longlat"}: + e, n = utils.DMS2Deg(e, n) + proj, coord1 = utils.ReprojectCoordinates( + coord=(e, n), projIn=projIn, projOut=projOut, flags="d" + ) + e, n = coord1 else: - # reproject values - projIn = settings - projOut = RunCommand("g.proj", flags="jf", read=True) - proj = projIn.split(" ")[0].split("=")[1] - if proj in {"ll", "latlong", "longlat"}: - e, n = utils.DMS2Deg(e, n) - proj, coord1 = utils.ReprojectCoordinates( - coord=(e, n), projIn=projIn, projOut=projOut, flags="d" - ) - e, n = coord1 - else: - e, n = float(e), float(n) - proj, coord1 = utils.ReprojectCoordinates( - coord=(e, n), projIn=projIn, projOut=projOut, flags="d" - ) - e, n = coord1 + e, n = float(e), float(n) + proj, coord1 = utils.ReprojectCoordinates( + coord=(e, n), projIn=projIn, projOut=projOut, flags="d" + ) + e, n = coord1 elif self.mapFrame.GetMap().projinfo["proj"] == "ll": e, n = utils.DMS2Deg(e, n) else: @@ -620,32 +619,28 @@ def GetCenterString(self, map): if self.mapFrame.GetProperty("useDefinedProjection"): if not projection: raise SbException(_("Projection not defined (check the settings)")) - else: - proj, coord = utils.ReprojectCoordinates( - coord=(region["center_easting"], region["center_northing"]), - projOut=projection, - flags="d", - ) - if coord: - if proj in {"ll", "latlong", "longlat"} and format == "DMS": - return "%s" % utils.Deg2DMS( - coord[0], coord[1], precision=precision - ) - return "%.*f; %.*f" % (precision, coord[0], precision, coord[1]) - raise SbException(_("Error in projection (check the settings)")) - elif self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": + proj, coord = utils.ReprojectCoordinates( + coord=(region["center_easting"], region["center_northing"]), + projOut=projection, + flags="d", + ) + if coord: + if proj in {"ll", "latlong", "longlat"} and format == "DMS": + return "%s" % utils.Deg2DMS(coord[0], coord[1], precision=precision) + return "%.*f; %.*f" % (precision, coord[0], precision, coord[1]) + raise SbException(_("Error in projection (check the settings)")) + if self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": return "%s" % utils.Deg2DMS( region["center_easting"], region["center_northing"], precision=precision, ) - else: - return "%.*f; %.*f" % ( - precision, - region["center_easting"], - precision, - region["center_northing"], - ) + return "%.*f; %.*f" % ( + precision, + region["center_easting"], + precision, + region["center_northing"], + ) def SetCenter(self): """Set current map center as item value""" @@ -795,21 +790,19 @@ def ReprojectENFromMap(self, e, n, useDefinedProjection, precision, format): ) if not settings: raise SbException(_("Projection not defined (check the settings)")) - else: - # reproject values - proj, coord = utils.ReprojectCoordinates( - coord=(e, n), projOut=settings, flags="d" - ) - if coord: - e, n = coord - if proj in {"ll", "latlong", "longlat"} and format == "DMS": - return utils.Deg2DMS(e, n, precision=precision) - return "%.*f; %.*f" % (precision, e, precision, n) - raise SbException(_("Error in projection (check the settings)")) - elif self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": + # reproject values + proj, coord = utils.ReprojectCoordinates( + coord=(e, n), projOut=settings, flags="d" + ) + if coord: + e, n = coord + if proj in {"ll", "latlong", "longlat"} and format == "DMS": + return utils.Deg2DMS(e, n, precision=precision) + return "%.*f; %.*f" % (precision, e, precision, n) + raise SbException(_("Error in projection (check the settings)")) + if self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": return utils.Deg2DMS(e, n, precision=precision) - else: - return "%.*f; %.*f" % (precision, e, precision, n) + return "%.*f; %.*f" % (precision, e, precision, n) class SbRegionExtent(SbTextItem): @@ -872,54 +865,53 @@ def ReprojectRegionFromMap(self, region, useDefinedProjection, precision, format if not settings: raise SbException(_("Projection not defined (check the settings)")) - else: - projOut = settings - proj, coord1 = utils.ReprojectCoordinates( - coord=(region["w"], region["s"]), projOut=projOut, flags="d" - ) - proj, coord2 = utils.ReprojectCoordinates( - coord=(region["e"], region["n"]), projOut=projOut, flags="d" - ) - # useless, used in derived class - proj, coord3 = utils.ReprojectCoordinates( - coord=(0.0, 0.0), projOut=projOut, flags="d" - ) - proj, coord4 = utils.ReprojectCoordinates( - coord=(region["ewres"], region["nsres"]), projOut=projOut, flags="d" - ) - if coord1 and coord2: - if proj in {"ll", "latlong", "longlat"} and format == "DMS": - w, s = utils.Deg2DMS( - coord1[0], coord1[1], string=False, precision=precision - ) - e, n = utils.Deg2DMS( - coord2[0], coord2[1], string=False, precision=precision - ) - ewres, nsres = utils.Deg2DMS( - abs(coord3[0]) - abs(coord4[0]), - abs(coord3[1]) - abs(coord4[1]), - string=False, - hemisphere=False, - precision=precision, - ) - return self._formatRegion( - w=w, s=s, e=e, n=n, ewres=ewres, nsres=nsres - ) - w, s = coord1 - e, n = coord2 - ewres, nsres = coord3 - return self._formatRegion( - w=w, - s=s, - e=e, - n=n, - ewres=ewres, - nsres=nsres, + projOut = settings + proj, coord1 = utils.ReprojectCoordinates( + coord=(region["w"], region["s"]), projOut=projOut, flags="d" + ) + proj, coord2 = utils.ReprojectCoordinates( + coord=(region["e"], region["n"]), projOut=projOut, flags="d" + ) + # useless, used in derived class + proj, coord3 = utils.ReprojectCoordinates( + coord=(0.0, 0.0), projOut=projOut, flags="d" + ) + proj, coord4 = utils.ReprojectCoordinates( + coord=(region["ewres"], region["nsres"]), projOut=projOut, flags="d" + ) + if coord1 and coord2: + if proj in {"ll", "latlong", "longlat"} and format == "DMS": + w, s = utils.Deg2DMS( + coord1[0], coord1[1], string=False, precision=precision + ) + e, n = utils.Deg2DMS( + coord2[0], coord2[1], string=False, precision=precision + ) + ewres, nsres = utils.Deg2DMS( + abs(coord3[0]) - abs(coord4[0]), + abs(coord3[1]) - abs(coord4[1]), + string=False, + hemisphere=False, precision=precision, ) - raise SbException(_("Error in projection (check the settings)")) + return self._formatRegion( + w=w, s=s, e=e, n=n, ewres=ewres, nsres=nsres + ) + w, s = coord1 + e, n = coord2 + ewres, nsres = coord3 + return self._formatRegion( + w=w, + s=s, + e=e, + n=n, + ewres=ewres, + nsres=nsres, + precision=precision, + ) + raise SbException(_("Error in projection (check the settings)")) - elif self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": + if self.mapFrame.GetMap().projinfo["proj"] == "ll" and format == "DMS": w, s = utils.Deg2DMS( region["w"], region["s"], string=False, precision=precision ) @@ -930,13 +922,12 @@ def ReprojectRegionFromMap(self, region, useDefinedProjection, precision, format region["ewres"], region["nsres"], string=False, precision=precision ) return self._formatRegion(w=w, s=s, e=e, n=n, ewres=ewres, nsres=nsres) - else: - w, s = region["w"], region["s"] - e, n = region["e"], region["n"] - ewres, nsres = region["ewres"], region["nsres"] - return self._formatRegion( - w=w, s=s, e=e, n=n, ewres=ewres, nsres=nsres, precision=precision - ) + w, s = region["w"], region["s"] + e, n = region["e"], region["n"] + ewres, nsres = region["ewres"], region["nsres"] + return self._formatRegion( + w=w, s=s, e=e, n=n, ewres=ewres, nsres=nsres, precision=precision + ) class SbCompRegionExtent(SbRegionExtent): diff --git a/gui/wxpython/timeline/frame.py b/gui/wxpython/timeline/frame.py index 7ca51cd8989..492713ba7a8 100644 --- a/gui/wxpython/timeline/frame.py +++ b/gui/wxpython/timeline/frame.py @@ -520,7 +520,7 @@ def _checkDatasets(self, datasets): if len(indices) == 0: raise GException(errorMsg) - elif len(indices) >= 2: + if len(indices) >= 2: dlg = wx.SingleChoiceDialog( self, message=_("Please specify the space time dataset <%s>.") % dataset, diff --git a/gui/wxpython/tplot/frame.py b/gui/wxpython/tplot/frame.py index f52c5a4d190..79e1cdb3709 100755 --- a/gui/wxpython/tplot/frame.py +++ b/gui/wxpython/tplot/frame.py @@ -1178,7 +1178,7 @@ def _checkDatasets(self, datasets, typ): if len(indices) == 0: raise GException(errorMsg) - elif len(indices) >= 2: + if len(indices) >= 2: dlg = wx.SingleChoiceDialog( self, message=_("Please specify the space time dataset <%s>.") % dataset, diff --git a/pyproject.toml b/pyproject.toml index 9c358cc0c93..5e84a809256 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -209,7 +209,6 @@ ignore = [ "RET501", # unnecessary-return-none "RET502", # implicit-return-value "RET503", # implicit-return - "RET506", # superfluous-else-raise "RET507", # superfluous-else-continue "RUF003", # ambiguous-unicode-character-comment "RUF005", # collection-literal-concatenation diff --git a/python/grass/imaging/images2avi.py b/python/grass/imaging/images2avi.py index 1b0d9d8cd20..9776b9c0db2 100644 --- a/python/grass/imaging/images2avi.py +++ b/python/grass/imaging/images2avi.py @@ -141,19 +141,18 @@ def writeAvi( print(gs.decode(outPut)) print(gs.decode(S.stderr.read())) raise RuntimeError(_("Could not write avi.")) - else: - try: - # Copy avi - shutil.copy(os.path.join(tempDir, "output.avi"), filename) - except Exception as err: - # Clean up - _cleanDir(tempDir) - if bg_task: - return str(err) - raise - + try: + # Copy avi + shutil.copy(os.path.join(tempDir, "output.avi"), filename) + except Exception as err: # Clean up _cleanDir(tempDir) + if bg_task: + return str(err) + raise + + # Clean up + _cleanDir(tempDir) def readAvi(filename, asNumpy=True): @@ -195,11 +194,11 @@ def readAvi(filename, asNumpy=True): # Clean up _cleanDir(tempDir) raise RuntimeError("Could not read avi.") - else: - # Read images - images = images2ims.readIms(os.path.join(tempDir, "im*.jpg"), asNumpy) - # Clean up - _cleanDir(tempDir) + + # Read images + images = images2ims.readIms(os.path.join(tempDir, "im*.jpg"), asNumpy) + # Clean up + _cleanDir(tempDir) # Done return images diff --git a/python/grass/pygrass/gis/__init__.py b/python/grass/pygrass/gis/__init__.py index 597c4bf75fa..29fecd3d699 100644 --- a/python/grass/pygrass/gis/__init__.py +++ b/python/grass/pygrass/gis/__init__.py @@ -114,7 +114,7 @@ def make_mapset(mapset, location=None, gisdbase=None): res = libgis.G_make_mapset(gisdbase, location, mapset) if res == -1: raise GrassError("Cannot create new mapset") - elif res == -2: + if res == -2: raise GrassError("Illegal name") diff --git a/python/grass/pygrass/messages/__init__.py b/python/grass/pygrass/messages/__init__.py index 36356433381..54d9af1b1c5 100644 --- a/python/grass/pygrass/messages/__init__.py +++ b/python/grass/pygrass/messages/__init__.py @@ -262,8 +262,7 @@ def fatal(self, message): if self.raise_on_error is True: raise FatalError(message) - else: - sys.exit(1) + sys.exit(1) def debug(self, level, message): """Send a debug message to stderr diff --git a/python/grass/pygrass/modules/interface/parameter.py b/python/grass/pygrass/modules/interface/parameter.py index 3b58ea2b372..e4235529b7a 100644 --- a/python/grass/pygrass/modules/interface/parameter.py +++ b/python/grass/pygrass/modules/interface/parameter.py @@ -18,15 +18,15 @@ def _check_value(param, value): string = (bytes, str) def raiseexcpet(exc, param, ptype, value): - """Function to modifa the error message""" + """Function to modify the error message""" msg = req % (param.name, param.typedesc, ptype, value, str(exc)) if isinstance(exc, ValueError): raise ValueError(msg) - elif isinstance(exc, TypeError): + if isinstance(exc, TypeError): raise TypeError(msg) - else: - exc.message = msg - raise exc + + exc.message = msg + raise exc def check_string(value): """Function to check that a string parameter is already a string""" diff --git a/python/grass/pygrass/raster/category.py b/python/grass/pygrass/raster/category.py index fa4e8d37b12..9c34bb8390f 100644 --- a/python/grass/pygrass/raster/category.py +++ b/python/grass/pygrass/raster/category.py @@ -189,7 +189,7 @@ def _set_c_cat(self, label, min_cat, max_cat=None): return None if err == 0: raise GrassError(_("Null value detected")) - elif err == -1: + if err == -1: raise GrassError(_("Error executing: Rast_set_cat")) def __del__(self): diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py index 9c8d0c3f9a2..d5417a00618 100644 --- a/python/grass/pygrass/vector/table.py +++ b/python/grass/pygrass/vector/table.py @@ -134,8 +134,7 @@ def limit(self, number): """ if not isinstance(number, int): raise ValueError("Must be an integer.") - else: - self._limit = "LIMIT {number}".format(number=number) + self._limit = "LIMIT {number}".format(number=number) return self def group_by(self, *groupby): diff --git a/python/grass/script/task.py b/python/grass/script/task.py index cf398c59214..ef2a77ad90d 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -153,8 +153,7 @@ def get_param(self, value, element="name", raiseError=True): _("Parameter element '%(element)s' not found: '%(value)s'") % {"element": element, "value": value} ) - else: - return None + return None def get_flag(self, aFlag): """Find and return a flag by name diff --git a/python/grass/temporal/temporal_algebra.py b/python/grass/temporal/temporal_algebra.py index b143488c863..a561ee8d1b9 100644 --- a/python/grass/temporal/temporal_algebra.py +++ b/python/grass/temporal/temporal_algebra.py @@ -1245,42 +1245,41 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True): _("Space time %s dataset <%s> not found") % (stds.get_new_map_instance(None).get_type(), id_input) ) + # Select temporal dataset entry from database. + stds.select(dbif=self.dbif) + if self.use_granularity: + # We create the maplist out of the map array from none-gap objects + maplist = [] + map_array = stds.get_registered_maps_as_objects_by_granularity( + gran=self.granularity, dbif=self.dbif + ) + for entry in map_array: + # Ignore gap objects + if entry[0].get_id() is not None: + maplist.append(entry[0]) else: - # Select temporal dataset entry from database. - stds.select(dbif=self.dbif) - if self.use_granularity: - # We create the maplist out of the map array from none-gap objects - maplist = [] - map_array = stds.get_registered_maps_as_objects_by_granularity( - gran=self.granularity, dbif=self.dbif - ) - for entry in map_array: - # Ignore gap objects - if entry[0].get_id() is not None: - maplist.append(entry[0]) - else: - maplist = stds.get_registered_maps_as_objects(dbif=self.dbif) - # Create map_value as empty list item. - for map_i in maplist: - if "map_value" not in dir(map_i): - map_i.map_value = [] - if "condition_value" not in dir(map_i): - map_i.condition_value = [] - # Set and check global temporal type variable and map. - if map_i.is_time_absolute() and self.temporaltype is None: - self.temporaltype = "absolute" - elif map_i.is_time_relative() and self.temporaltype is None: - self.temporaltype = "relative" - elif ( - map_i.is_time_absolute() and self.temporaltype == "relative" - ) or (map_i.is_time_relative() and self.temporaltype == "absolute"): - self.msgr.fatal( - _( - "Wrong temporal type of space time dataset " - "<%s> <%s> time is required" - ) - % (id_input, self.temporaltype) + maplist = stds.get_registered_maps_as_objects(dbif=self.dbif) + # Create map_value as empty list item. + for map_i in maplist: + if "map_value" not in dir(map_i): + map_i.map_value = [] + if "condition_value" not in dir(map_i): + map_i.condition_value = [] + # Set and check global temporal type variable and map. + if map_i.is_time_absolute() and self.temporaltype is None: + self.temporaltype = "absolute" + elif map_i.is_time_relative() and self.temporaltype is None: + self.temporaltype = "relative" + elif (map_i.is_time_absolute() and self.temporaltype == "relative") or ( + map_i.is_time_relative() and self.temporaltype == "absolute" + ): + self.msgr.fatal( + _( + "Wrong temporal type of space time dataset " + "<%s> <%s> time is required" ) + % (id_input, self.temporaltype) + ) elif isinstance(input, self.mapclass): # Check if the input is a single map and return it as list with one entry. maplist = [input] @@ -2651,9 +2650,9 @@ def p_expr_tmap_function(self, t): _("%s map <%s> not found in GRASS spatial database") % (map_i.get_type(), id_input) ) - else: - # Select dataset entry from database. - map_i.select(dbif=self.dbif) + + # Select dataset entry from database. + map_i.select(dbif=self.dbif) else: raise FatalError( _( @@ -3400,8 +3399,7 @@ def p_error(self, t): "syntax error on line %d, position %i token %s near '%s' expression " "'%s'" % (t.lineno, t.lexpos, t.type, t.value, self.expression) ) - else: - raise SyntaxError("Unexpected syntax error") + raise SyntaxError("Unexpected syntax error") if __name__ == "__main__": diff --git a/python/grass/temporal/temporal_operator.py b/python/grass/temporal/temporal_operator.py index 7d91ed0f65c..d99244c7c49 100644 --- a/python/grass/temporal/temporal_operator.py +++ b/python/grass/temporal/temporal_operator.py @@ -352,16 +352,16 @@ def p_relation_operator(self, t): # Check for correct type. if not self.optype == "relation": raise SyntaxError('Wrong optype "%s" must be "relation"' % self.optype) + + # Set three operator components. + if isinstance(t[2], list): + self.relations = t[2] else: - # Set three operator components. - if isinstance(t[2], list): - self.relations = t[2] - else: - self.relations = [t[2]] - self.temporal = None - self.function = None + self.relations = [t[2]] + self.temporal = None + self.function = None - t[0] = t[2] + t[0] = t[2] def p_relation_bool_operator(self, t): # {||, during} @@ -374,17 +374,17 @@ def p_relation_bool_operator(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = "l" - self.function = t[2] + t[3] - self.aggregate = t[2] + self.relations = [t[5]] + self.temporal = "l" + self.function = t[2] + t[3] + self.aggregate = t[2] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator(self, t): # {||, during, &} @@ -401,17 +401,17 @@ def p_relation_bool_combi_operator(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = "l" - self.function = t[2] + t[3] - self.aggregate = t[7] + self.relations = [t[5]] + self.temporal = "l" + self.function = t[2] + t[3] + self.aggregate = t[7] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator2(self, t): # {||, during, left} @@ -424,17 +424,17 @@ def p_relation_bool_combi_operator2(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = t[7] - self.function = t[2] + t[3] - self.aggregate = t[2] + self.relations = [t[5]] + self.temporal = t[7] + self.function = t[2] + t[3] + self.aggregate = t[2] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator3(self, t): # {||, during, |, left} @@ -451,17 +451,17 @@ def p_relation_bool_combi_operator3(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "relation"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = t[9] - self.function = t[2] + t[3] - self.aggregate = t[7] + self.relations = [t[5]] + self.temporal = t[9] + self.function = t[2] + t[3] + self.aggregate = t[7] - t[0] = t[2] + t[0] = t[2] def p_select_relation_operator(self, t): # {!:} @@ -477,27 +477,28 @@ def p_select_relation_operator(self, t): """ if not self.optype == "select": raise SyntaxError('Wrong optype "%s" must be "select"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal", "equivalent"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal", "equivalent"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_hash_relation_operator(self, t): # {#} @@ -513,27 +514,28 @@ def p_hash_relation_operator(self, t): """ if not self.optype == "hash": raise SyntaxError('Wrong optype "%s" must be "hash"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_raster_relation_operator(self, t): # {+} @@ -549,27 +551,28 @@ def p_raster_relation_operator(self, t): """ if not self.optype == "raster": raise SyntaxError('Wrong optype "%s" must be "raster"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_overlay_relation_operator(self, t): # {+} @@ -585,27 +588,28 @@ def p_overlay_relation_operator(self, t): """ if not self.optype == "overlay": raise SyntaxError('Wrong optype "%s" must be "overlay"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_relation(self, t): # The list of relations. Temporal and spatial relations are supported diff --git a/python/grass/temporal/temporal_raster_base_algebra.py b/python/grass/temporal/temporal_raster_base_algebra.py index ef720b52c4e..76214f0250c 100644 --- a/python/grass/temporal/temporal_raster_base_algebra.py +++ b/python/grass/temporal/temporal_raster_base_algebra.py @@ -972,12 +972,11 @@ def p_expr_spmap_function(self, t): _("%s map <%s> not found in GRASS spatial database") % (map_i.get_type(), id_input) ) - else: - # Select dataset entry from database. - map_i.select(dbif=self.dbif) - # Create command list for map object. - cmdstring = "(%s)" % (map_i.get_map_id()) - map_i.cmd_list = cmdstring + # Select dataset entry from database. + map_i.select(dbif=self.dbif) + # Create command list for map object. + cmdstring = "(%s)" % (map_i.get_map_id()) + map_i.cmd_list = cmdstring # Return map object. t[0] = cmdstring else: diff --git a/scripts/r.in.wms/wms_cap_parsers.py b/scripts/r.in.wms/wms_cap_parsers.py index 56b1d0ce48c..0a8dc37300c 100644 --- a/scripts/r.in.wms/wms_cap_parsers.py +++ b/scripts/r.in.wms/wms_cap_parsers.py @@ -105,8 +105,7 @@ def __init__(self, cap_file, force_version=None): raise ParseError( _("Missing version attribute root node in Capabilities XML file") ) - else: - wms_version = self.getroot().attrib["version"] + wms_version = self.getroot().attrib["version"] if wms_version == "1.3.0": self.proj_tag = "CRS" From 12513f89f6424c2ce378fe2081c0d6e09651ba9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 21 Oct 2024 01:56:03 +0000 Subject: [PATCH 3/3] style: Fix superfluous-else-continue (RET507) Ruff rule: https://docs.astral.sh/ruff/rules/superfluous-else-continue --- gui/wxpython/animation/temporal_manager.py | 7 +++---- gui/wxpython/core/gcmd.py | 2 +- gui/wxpython/core/render.py | 16 ++++++++-------- gui/wxpython/dbmgr/dialogs.py | 17 ++++++++--------- gui/wxpython/location_wizard/wizard.py | 3 +-- gui/wxpython/nviz/tools.py | 7 +++---- gui/wxpython/psmap/instructions.py | 2 +- gui/wxpython/vnet/dialogs.py | 10 +++++----- gui/wxpython/vnet/vnet_data.py | 7 +++---- man/build_class_graphical.py | 2 +- pyproject.toml | 1 - scripts/r.in.wms/wms_drv.py | 3 +-- 12 files changed, 35 insertions(+), 42 deletions(-) diff --git a/gui/wxpython/animation/temporal_manager.py b/gui/wxpython/animation/temporal_manager.py index ef782543089..273d9d05ef8 100644 --- a/gui/wxpython/animation/temporal_manager.py +++ b/gui/wxpython/animation/temporal_manager.py @@ -299,10 +299,9 @@ def _getLabelsAndMaps(self, timeseries): # skip this one, already there followsPoint = False continue - else: - # append the last one (of point time) - listOfMaps.append(lastTimeseries) - end = None + # append the last one (of point time) + listOfMaps.append(lastTimeseries) + end = None else: # append series which is None listOfMaps.append(series) diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index b22f0bc915d..542d6736a88 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -643,7 +643,7 @@ def _formatMsg(text): for line in text.splitlines(): if len(line) == 0: continue - elif ( + if ( "GRASS_INFO_MESSAGE" in line or "GRASS_INFO_WARNING" in line or "GRASS_INFO_ERROR" in line diff --git a/gui/wxpython/core/render.py b/gui/wxpython/core/render.py index 2db3287bf78..71d77fb1164 100644 --- a/gui/wxpython/core/render.py +++ b/gui/wxpython/core/render.py @@ -1190,32 +1190,32 @@ def SetRegion(self, windres=False, windres3=False): if key == "north": grass_region += "north: %s; " % (region["n"]) continue - elif key == "south": + if key == "south": grass_region += "south: %s; " % (region["s"]) continue - elif key == "east": + if key == "east": grass_region += "east: %s; " % (region["e"]) continue - elif key == "west": + if key == "west": grass_region += "west: %s; " % (region["w"]) continue - elif key == "e-w resol": + if key == "e-w resol": grass_region += "e-w resol: %.10f; " % (region["ewres"]) continue - elif key == "n-s resol": + if key == "n-s resol": grass_region += "n-s resol: %.10f; " % (region["nsres"]) continue - elif key == "cols": + if key == "cols": if windres: continue grass_region += "cols: %d; " % region["cols"] continue - elif key == "rows": + if key == "rows": if windres: continue grass_region += "rows: %d; " % region["rows"] continue - elif key == "n-s resol3" and windres3: + if key == "n-s resol3" and windres3: grass_region += "n-s resol3: %f; " % (region["nsres3"]) elif key == "e-w resol3" and windres3: grass_region += "e-w resol3: %f; " % (region["ewres3"]) diff --git a/gui/wxpython/dbmgr/dialogs.py b/gui/wxpython/dbmgr/dialogs.py index 0d7c6e9e523..5009a13e2ea 100644 --- a/gui/wxpython/dbmgr/dialogs.py +++ b/gui/wxpython/dbmgr/dialogs.py @@ -654,15 +654,14 @@ def __init__( self.boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) cId += 1 continue - else: - valueWin = SpinCtrl( - parent=self.dataPanel, - id=wx.ID_ANY, - value=value, - min=-1e9, - max=1e9, - size=(250, -1), - ) + valueWin = SpinCtrl( + parent=self.dataPanel, + id=wx.ID_ANY, + value=value, + min=-1e9, + max=1e9, + size=(250, -1), + ) else: valueWin = TextCtrl( parent=self.dataPanel, id=wx.ID_ANY, value=value, size=(250, -1) diff --git a/gui/wxpython/location_wizard/wizard.py b/gui/wxpython/location_wizard/wizard.py index 1f8de66dda6..ab292dae3b6 100644 --- a/gui/wxpython/location_wizard/wizard.py +++ b/gui/wxpython/location_wizard/wizard.py @@ -900,8 +900,7 @@ def OnPageChange(self, event=None): if param["type"] == "bool": if param["value"] is False: continue - else: - self.p4projparams += " +" + param["proj4"] + self.p4projparams += " +" + param["proj4"] elif param["value"] is None: wx.MessageBox( parent=self, diff --git a/gui/wxpython/nviz/tools.py b/gui/wxpython/nviz/tools.py index 7ced7d157e1..da7e44ac78a 100644 --- a/gui/wxpython/nviz/tools.py +++ b/gui/wxpython/nviz/tools.py @@ -3947,8 +3947,7 @@ def OnSurfacePosition(self, event): self.win["surface"]["position"]["reset"], }: continue - else: - self.FindWindowById(win).SetValue(value) + self.FindWindowById(win).SetValue(value) data = self.GetLayerData("surface") id = data["surface"]["object"]["id"] @@ -4767,8 +4766,8 @@ def OnVolumePosition(self, event): self.win["volume"]["position"]["reset"], }: continue - else: - self.FindWindowById(win).SetValue(value) + + self.FindWindowById(win).SetValue(value) data = self.GetLayerData("volume") id = data["volume"]["object"]["id"] diff --git a/gui/wxpython/psmap/instructions.py b/gui/wxpython/psmap/instructions.py index 2e558949023..dfb2e99fe72 100644 --- a/gui/wxpython/psmap/instructions.py +++ b/gui/wxpython/psmap/instructions.py @@ -223,7 +223,7 @@ def Read(self, filename): buffer = [] continue - elif line.startswith("paper"): + if line.startswith("paper"): instruction = "paper" isBuffer = True buffer.append(line) diff --git a/gui/wxpython/vnet/dialogs.py b/gui/wxpython/vnet/dialogs.py index 242c1a5b9b4..cbf3e152e99 100644 --- a/gui/wxpython/vnet/dialogs.py +++ b/gui/wxpython/vnet/dialogs.py @@ -647,11 +647,11 @@ def _updateInputDbMgrData(self): if inpLayer in browseLayers: needLayers.append(inpLayer) continue - else: - wx.BeginBusyCursor() - self.inpDbMgrData["browse"].AddLayer(inpLayer) - wx.EndBusyCursor() - needLayers.append(inpLayer) + + wx.BeginBusyCursor() + self.inpDbMgrData["browse"].AddLayer(inpLayer) + wx.EndBusyCursor() + needLayers.append(inpLayer) for layer in browseLayers: if layer not in needLayers: diff --git a/gui/wxpython/vnet/vnet_data.py b/gui/wxpython/vnet/vnet_data.py index ee6159eb403..e3f93c213b9 100644 --- a/gui/wxpython/vnet/vnet_data.py +++ b/gui/wxpython/vnet/vnet_data.py @@ -1195,9 +1195,8 @@ def _savePreviousHist(self, newHist, oldHist): if newHistStepsNum >= self.maxHistSteps: removedHistStep = removedHistData[line] = {} continue - else: - newHist.write("%s%s%s" % ("\n", line, "\n")) - self.histStepsNum = newHistStepsNum + newHist.write("%s%s%s" % ("\n", line, "\n")) + self.histStepsNum = newHistStepsNum elif newHistStepsNum >= self.maxHistSteps: self._parseLine(line, removedHistStep) else: @@ -1300,7 +1299,7 @@ def _getHistStepData(self, histStep): if not line.strip(): newHistStep = True continue - elif isSearchedHistStep: + if isSearchedHistStep: self._parseLine(line, histStepData) if newHistStep: diff --git a/man/build_class_graphical.py b/man/build_class_graphical.py index 554c950d3a8..83338f1942c 100644 --- a/man/build_class_graphical.py +++ b/man/build_class_graphical.py @@ -165,7 +165,7 @@ def generate_page_for_category( img_class = "linkimg" if skip_no_image and not img: continue - elif not img: + if not img: img = "grass_logo.png" img_class = "default-img" if basename.startswith("wxGUI"): diff --git a/pyproject.toml b/pyproject.toml index 5e84a809256..5c5d036d283 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -209,7 +209,6 @@ ignore = [ "RET501", # unnecessary-return-none "RET502", # implicit-return-value "RET503", # implicit-return - "RET507", # superfluous-else-continue "RUF003", # ambiguous-unicode-character-comment "RUF005", # collection-literal-concatenation "RUF012", # mutable-class-default diff --git a/scripts/r.in.wms/wms_drv.py b/scripts/r.in.wms/wms_drv.py index 531112a1a6c..37620fd3b7f 100644 --- a/scripts/r.in.wms/wms_drv.py +++ b/scripts/r.in.wms/wms_drv.py @@ -155,8 +155,7 @@ def _download(self): sleep(sleep_time) continue - else: - gs.fatal(_("Unable to write data into tempfile.\n%s") % str(e)) + gs.fatal(_("Unable to write data into tempfile.\n%s") % str(e)) finally: temp_tile_opened.close()