diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 7172835f001..cadbedce6f9 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -1802,10 +1802,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar value = self._getValue(p) if prompt == "layer": - if p.get("element", "layer") == "layer_all": - all = True - else: - all = False + all = bool(p.get("element", "layer") == "layer_all") if p.get("age", "old") == "old": win = gselect.LayerSelect( parent=which_panel, all=all, default=p["default"] diff --git a/gui/wxpython/modules/import_export.py b/gui/wxpython/modules/import_export.py index db4e3b517a2..c6e3b9c6d42 100644 --- a/gui/wxpython/modules/import_export.py +++ b/gui/wxpython/modules/import_export.py @@ -337,11 +337,9 @@ def AddLayers(self, returncode, cmd=None, userData=None): if self.importType == "gdal": nBands = int(userData.get("nbands", 1)) if userData else 1 - if UserSettings.Get(group="rasterLayer", key="opaque", subkey="enabled"): - nFlag = True - else: - nFlag = False - + nFlag = bool( + UserSettings.Get(group="rasterLayer", key="opaque", subkey="enabled") + ) for i in range(1, nBands + 1): nameOrig = name if nBands > 1: diff --git a/pyproject.toml b/pyproject.toml index 5ca5276b677..fab94860c3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -635,7 +635,6 @@ disable = [ "R0916", # (too-many-boolean-expressions) "R0917", # (too-many-positional-arguments) "R1702", # (too-many-nested-blocks) - "R1703", # The if statement can be replaced with %s (simplifiable-if-statement) "R1704", # Redefining argument with the local name %r (redefined-argument-from-local) "R1705", # Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return) "R1710", # Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) diff --git a/python/grass/script/task.py b/python/grass/script/task.py index 758372938e3..5d7355efacb 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -313,7 +313,7 @@ def _process_module(self): self.task.label = self._get_node_text(self.root, "label") self.task.description = self._get_node_text(self.root, "description") - def _process_params(self): + def _process_params(self) -> None: """Process parameters""" for p in self.root.findall("parameter"): # gisprompt @@ -347,15 +347,12 @@ def _process_params(self): multiple = p.get("multiple", "no") == "yes" required = p.get("required", "no") == "yes" - if ( + hidden: bool = bool( self.task.blackList["enabled"] and self.task.name in self.task.blackList["items"] and p.get("name") in self.task.blackList["items"][self.task.name].get("params", []) - ): - hidden = True - else: - hidden = False + ) self.task.params.append( { @@ -380,23 +377,17 @@ def _process_params(self): } ) - def _process_flags(self): + def _process_flags(self) -> None: """Process flags""" for p in self.root.findall("flag"): - if ( + hidden: bool = bool( self.task.blackList["enabled"] and self.task.name in self.task.blackList["items"] and p.get("name") in self.task.blackList["items"][self.task.name].get("flags", []) - ): - hidden = True - else: - hidden = False - - if p.find("suppress_required") is not None: - suppress_required = True - else: - suppress_required = False + ) + + suppress_required: bool = bool(p.find("suppress_required") is not None) self.task.flags.append( {