diff --git a/gui/wxpython/core/render.py b/gui/wxpython/core/render.py index 40cd82defc2..77f4fcbdb94 100644 --- a/gui/wxpython/core/render.py +++ b/gui/wxpython/core/render.py @@ -882,7 +882,7 @@ def _projInfo(self): for line in ret.splitlines(): if ":" in line: - key, val = map(lambda x: x.strip(), line.split(":", 1)) + key, val = (x.strip() for x in line.split(":", 1)) if key in {"units"}: val = val.lower() projinfo[key] = val diff --git a/gui/wxpython/core/utils.py b/gui/wxpython/core/utils.py index fd6803ecf74..3eedc619772 100644 --- a/gui/wxpython/core/utils.py +++ b/gui/wxpython/core/utils.py @@ -659,7 +659,7 @@ def _parseFormats(output, writableOnly=False): patt = re.compile(r"\(rw\+?\)$", re.IGNORECASE) for line in output.splitlines(): - key, name = map(lambda x: x.strip(), line.strip().split(":", 1)) + key, name = (x.strip() for x in line.strip().split(":", 1)) if writableOnly and not patt.search(key): continue @@ -843,7 +843,7 @@ def StoreEnvVariable(key, value=None, envFile=None): for line in fd.readlines(): line = line.rstrip(os.linesep) try: - k, v = map(lambda x: x.strip(), line.split(" ", 1)[1].split("=", 1)) + k, v = (x.strip() for x in line.split(" ", 1)[1].split("=", 1)) except Exception as e: sys.stderr.write( _("%s: line skipped - unable to parse '%s'\nReason: %s\n") diff --git a/gui/wxpython/gmodeler/dialogs.py b/gui/wxpython/gmodeler/dialogs.py index 044dedff680..10729b83289 100644 --- a/gui/wxpython/gmodeler/dialogs.py +++ b/gui/wxpython/gmodeler/dialogs.py @@ -944,15 +944,11 @@ def Populate(self, data): items = self.frame.GetModel().GetItems(objType=ModelAction) if isinstance(self.shape, ModelCondition): if self.GetLabel() == "ElseBlockList": - shapeItems = map( - lambda x: x.GetId(), self.shape.GetItems(items)["else"] - ) + shapeItems = (x.GetId() for x in self.shape.GetItems(items)["else"]) else: - shapeItems = map( - lambda x: x.GetId(), self.shape.GetItems(items)["if"] - ) + shapeItems = (x.GetId() for x in self.shape.GetItems(items)["if"]) else: - shapeItems = map(lambda x: x.GetId(), self.shape.GetItems(items)) + shapeItems = (x.GetId() for x in self.shape.GetItems(items)) else: shapeItems = [] diff --git a/gui/wxpython/gmodeler/model.py b/gui/wxpython/gmodeler/model.py index d729c43a87a..864f1df68e9 100644 --- a/gui/wxpython/gmodeler/model.py +++ b/gui/wxpython/gmodeler/model.py @@ -493,7 +493,7 @@ def Validate(self): cmd = action.GetLog(string=False) task = GUI(show=None).ParseCommand(cmd=cmd) - errList += map(lambda x: cmd[0] + ": " + x, task.get_cmd_error()) + errList += (cmd[0] + ": " + x for x in task.get_cmd_error()) # check also variables for opt in cmd[1:]: @@ -695,7 +695,7 @@ def Run(self, log, onDone, parent=None): parent=parent, message=_("Variables below not defined:") + "\n\n" - + "\n".join(map(lambda x: "%s: %s (%s)" % (x[0], x[1], x[2]), err)), + + "\n".join(f"{x[0]}: {x[1]} ({x[2]})" for x in err), ) return @@ -735,9 +735,7 @@ def Run(self, log, onDone, parent=None): # split condition # TODO: this part needs some better solution - condVar, condText = map( - lambda x: x.strip(), re.split(r"\s* in \s*", cond) - ) + condVar, condText = (x.strip() for x in re.split(r"\s* in \s*", cond)) pattern = re.compile("%" + condVar) # for vars()[condVar] in eval(condText): ? vlist = [] @@ -2668,9 +2666,7 @@ def _writeItem(self, item, ignoreBlock=True, variables={}): value = '"' + value + '"' cond = pattern.sub(value, cond) if isinstance(item, ModelLoop): - condVar, condText = map( - lambda x: x.strip(), re.split(r"\s* in \s*", cond) - ) + condVar, condText = (x.strip() for x in re.split(r"\s* in \s*", cond)) cond = "%sfor %s in " % (" " * self.indent, condVar) if condText[0] == "`" and condText[-1] == "`": task = GUI(show=None).ParseCommand(cmd=utils.split(condText[1:-1])) @@ -3499,21 +3495,21 @@ def cleanup(): r""" %s("g.remove", flags="f", type="raster", name=%s) """ - % (run_command, ",".join(map(lambda x: '"' + x + '"', rast))) + % (run_command, ",".join(f'"{x}"' for x in rast3d)) ) if vect: self.fd.write( r""" %s("g.remove", flags="f", type="vector", name=%s) """ - % (run_command, ",".join(map(lambda x: '"' + x + '"', vect))) + % (run_command, ",".join(('"' + x + '"' for x in vect))) ) if rast3d: self.fd.write( r""" %s("g.remove", flags="f", type="raster_3d", name=%s) """ - % (run_command, ",".join(map(lambda x: '"' + x + '"', rast3d))) + % (run_command, ",".join(f'"{x}"' for x in rast3d)) ) if not rast and not vect and not rast3d: self.fd.write(" pass\n") diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 95cbf55d7e9..00fd505c799 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -2490,7 +2490,7 @@ def OnCheckItem(index=None, flag=None, event=None): tab[section].SetupScrolling(True, True, 10, 10) tab[section].Layout() minsecsizes = tabsizer[section].GetSize() - maxsizes = list(map(lambda x: max(maxsizes[x], minsecsizes[x]), (0, 1))) + maxsizes = [max(maxsizes[x], minsecsizes[x]) for x in (0, 1)] # TODO: be less arbitrary with these 600 self.panelMinHeight = 100 diff --git a/gui/wxpython/gui_core/gselect.py b/gui/wxpython/gui_core/gselect.py index bed849f0c26..6b679c074b5 100644 --- a/gui/wxpython/gui_core/gselect.py +++ b/gui/wxpython/gui_core/gselect.py @@ -2291,8 +2291,8 @@ def hasRastSameProjAsLocation(dsn, table=None): lines = ret.splitlines() projectionMatch = "0" if lines: - bandNumber, bandType, projectionMatch = map( - lambda x: x.strip(), lines[0].split(",") + bandNumber, bandType, projectionMatch = ( + x.strip() for x in lines[0].split(",") ) return projectionMatch @@ -2321,8 +2321,8 @@ def getProjMatchCaption(projectionMatch): layerId = 1 for line in ret.splitlines(): - layerName, featureType, projectionMatch, geometryColumn = map( - lambda x: x.strip(), line.split(",") + layerName, featureType, projectionMatch, geometryColumn = ( + x.strip() for x in line.split(",") ) projectionMatchCaption = getProjMatchCaption(projectionMatch) grassName = GetValidLayerName(layerName) diff --git a/gui/wxpython/lmgr/frame.py b/gui/wxpython/lmgr/frame.py index 752f50bf597..0b5a07b8f07 100644 --- a/gui/wxpython/lmgr/frame.py +++ b/gui/wxpython/lmgr/frame.py @@ -1981,8 +1981,8 @@ def AddOrUpdateMap(self, mapName, ltype): self.AddMaps([mapName], ltype, check=True) else: display = self.GetMapDisplay() - mapLayers = map( - lambda x: x.GetName(), display.GetMap().GetListOfLayers(ltype=ltype) + mapLayers = ( + x.GetName() for x in display.GetMap().GetListOfLayers(ltype=ltype) ) if mapName in mapLayers: display.GetWindow().UpdateMap(render=True) diff --git a/gui/wxpython/main_window/frame.py b/gui/wxpython/main_window/frame.py index 361111d389f..41c6c57365f 100644 --- a/gui/wxpython/main_window/frame.py +++ b/gui/wxpython/main_window/frame.py @@ -2129,8 +2129,8 @@ def AddOrUpdateMap(self, mapName, ltype): self.AddMaps([mapName], ltype, check=True) else: display = self.GetMapDisplay() - mapLayers = map( - lambda x: x.GetName(), display.GetMap().GetListOfLayers(ltype=ltype) + mapLayers = ( + x.GetName() for x in display.GetMap().GetListOfLayers(ltype=ltype) ) if mapName in mapLayers: display.GetWindow().UpdateMap(render=True) diff --git a/gui/wxpython/modules/colorrules.py b/gui/wxpython/modules/colorrules.py index 6feeb22cab2..73cd2dac9b9 100644 --- a/gui/wxpython/modules/colorrules.py +++ b/gui/wxpython/modules/colorrules.py @@ -713,7 +713,7 @@ def ReadColorTable(self, ctable): minim = maxim = count = 0 for line in ctable.splitlines(): try: - value, color = map(lambda x: x.strip(), line.split(" ")) + value, color = (x.strip() for x in line.split(" ")) except ValueError: GMessage(parent=self, message=_("Invalid color table format")) self.rulesPanel.Clear() diff --git a/gui/wxpython/timeline/frame.py b/gui/wxpython/timeline/frame.py index a90fb44ffdb..0330adbde3d 100644 --- a/gui/wxpython/timeline/frame.py +++ b/gui/wxpython/timeline/frame.py @@ -572,9 +572,7 @@ def SetDatasets(self, datasets): GError(parent=self, message=str(error), showTraceback=False) return self.datasets = datasets - self.datasetSelect.SetValue( - ",".join(map(lambda x: x[0] + "@" + x[1], datasets)) - ) + self.datasetSelect.SetValue(",".join(f"{x[0]}@{x[1]}" for x in datasets)) self._redraw() def Show3D(self, show): diff --git a/gui/wxpython/tplot/frame.py b/gui/wxpython/tplot/frame.py index 48f8008412f..4a1cd9f1ca6 100755 --- a/gui/wxpython/tplot/frame.py +++ b/gui/wxpython/tplot/frame.py @@ -1268,7 +1268,7 @@ def SetDatasets( except: self.coorval.SetValue(",".join(coors)) if self.datasetsV: - vdatas = ",".join(map(lambda x: x[0] + "@" + x[1], self.datasetsV)) + vdatas = ",".join(f"{x[0]}@{x[1]}" for x in self.datasetsV) self.datasetSelectV.SetValue(vdatas) if attr: self.attribute.SetValue(attr) @@ -1276,7 +1276,7 @@ def SetDatasets( self.cats.SetValue(cats) if self.datasetsR: self.datasetSelectR.SetValue( - ",".join(map(lambda x: x[0] + "@" + x[1], self.datasetsR)) + ",".join(f"{x[0]}@{x[1]}" for x in self.datasetsR) ) if title: self.title.SetValue(title) diff --git a/pyproject.toml b/pyproject.toml index 268996612b7..25832ce3ea5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,6 @@ ignore = [ "C405", # unnecessary-literal-set "C414", # unnecessary-double-cast-or-process "C416", # unnecessary-comprehension - "C417", # unnecessary-map "C419", # unnecessary-comprehension-in-call "COM812", # missing-trailing-comma "COM818", # trailing-comma-on-bare-tuple diff --git a/python/grass/script/core.py b/python/grass/script/core.py index 6647661b379..a790307aa3c 100644 --- a/python/grass/script/core.py +++ b/python/grass/script/core.py @@ -218,9 +218,7 @@ def get_real_command(cmd): if os.path.splitext(cmd)[1] == ".py": cmd = cmd[:-3] # PATHEXT is necessary to check on Windows (force lowercase) - pathext = list( - map(lambda x: x.lower(), os.environ["PATHEXT"].split(os.pathsep)) - ) + pathext = [x.lower() for x in os.environ["PATHEXT"].split(os.pathsep)] if ".py" not in pathext: # we assume that PATHEXT contains always '.py' os.environ["PATHEXT"] = ".py;" + os.environ["PATHEXT"] @@ -1287,7 +1285,7 @@ def region_env(region3d=False, flags=None, env=None, **kwargs): with open(windfile, "r") as fd: grass_region = "" for line in fd.readlines(): - key, value = map(lambda x: x.strip(), line.split(":", 1)) + key, value = (x.strip() for x in line.split(":", 1)) if kwargs and key not in {"proj", "zone"}: continue if ( diff --git a/python/grass/semantic_label/reader.py b/python/grass/semantic_label/reader.py index bd19af69110..1da67aff7f9 100644 --- a/python/grass/semantic_label/reader.py +++ b/python/grass/semantic_label/reader.py @@ -181,7 +181,7 @@ def find_file(self, semantic_label): shortcut and config[root]["shortcut"].upper() == shortcut.upper() and band.upper() - in map(lambda x: x.upper(), config[root]["bands"].keys()) + in (x.upper() for x in config[root]["bands"].keys()) ): return filename