Skip to content

Commit

Permalink
style: Fix if-with-same-arms (SIM114) (#4406)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Sep 28, 2024
1 parent ead659f commit 70f3599
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 59 deletions.
4 changes: 1 addition & 3 deletions gui/wxpython/animation/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ def EvaluateInput(self, animationData):
mapCount.add(len(layer.maps))
windowIndex.append(anim.windowIndex)

if maps and stds:
temporalMode = TemporalMode.NONTEMPORAL
elif maps:
if (maps and stds) or maps:
temporalMode = TemporalMode.NONTEMPORAL
elif stds:
temporalMode = TemporalMode.TEMPORAL
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,11 @@ def _formatMsg(text):
for line in text.splitlines():
if len(line) == 0:
continue
elif "GRASS_INFO_MESSAGE" in line:
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_WARNING" in line:
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_ERROR" in line:
elif (
"GRASS_INFO_MESSAGE" in line
or "GRASS_INFO_WARNING" in line
or "GRASS_INFO_ERROR" in line
):
message += line.split(":", 1)[1].strip() + "\n"
elif "GRASS_INFO_END" in line:
return message
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,11 @@ def _deleteVertex(self, event):

coords = []
for i, tup in enumerate(self.pol.xy):
if i == ind:
continue
elif i == 0 and ind == len(self.pol.xy) - 1:
continue
elif i == len(self.pol.xy) - 1 and ind == 0:
if (
i == ind
or (i == 0 and ind == len(self.pol.xy) - 1)
or (i == len(self.pol.xy) - 1 and ind == 0)
):
continue

coords.append(tup)
Expand Down
14 changes: 6 additions & 8 deletions gui/wxpython/mapwin/decorations.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ def CmdIsValid(self) -> bool:
inputs = 0
for param in self._cmd[1:]:
param = param.split("=")
if len(param) == 1:
inputs += 1
elif param[0] == "text" and len(param) == 2:
if len(param) == 1 or (param[0] == "text" and len(param) == 2):
inputs += 1
return inputs >= 1

Expand Down Expand Up @@ -313,11 +311,11 @@ def CmdIsValid(self) -> bool:
inputs = 0
for param in self._cmd[1:]:
param = param.split("=")
if len(param) == 1:
inputs += 1
elif param[0] == "raster" and len(param) == 2:
inputs += 1
elif param[0] == "raster_3d" and len(param) == 2:
if (
len(param) == 1
or (param[0] == "raster" and len(param) == 2)
or (param[0] == "raster_3d" and len(param) == 2)
):
inputs += 1
return inputs == 1

Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/vdigit/wxdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,7 @@ def GetSelectedVertex(self, pos):
pos[0], pos[1], 0.0, points.x[idx], points.y[idx], points.z[idx], 0
)

if idx == 0:
minDist = dist
Gid = idx
elif minDist > dist:
if idx == 0 or minDist > dist:
minDist = dist
Gid = idx

Expand Down
4 changes: 1 addition & 3 deletions gui/wxpython/vnet/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,9 +1952,7 @@ def SetVirtualData(self, row, column, text):
text = DegreesToRadians(text)

# Tested allowed range of values
if text > math.pi:
text = 0.0
elif text < -math.pi:
if text > math.pi or text < -math.pi:
text = 0.0

self.data.SetValue(text, row, column)
Expand Down
4 changes: 1 addition & 3 deletions gui/wxpython/vnet/vnet_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,7 @@ def _prepareCmd(self, cmd):
if c.find("=") == -1:
continue
v = c.split("=")
if len(v) != 2:
cmd.remove(c)
elif not v[1].strip():
if len(v) != 2 or not v[1].strip():
cmd.remove(c)

def _setCmdForSpecificAn(self, cmdParams):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ ignore = [
"SIM109", # compare-with-tuple
"SIM110", # reimplemented-builtin
"SIM113", # enumerate-for-loop
"SIM114", # if-with-same-arms
"SIM116", # if-else-block-instead-of-dict-lookup
"SIM118", # in-dict-keys
"SIM223", # expr-and-false
Expand Down
7 changes: 3 additions & 4 deletions python/grass/script/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,9 @@ def get_lib_path(modname, libname=None):
getenv("GRASS_ADDON_BASE")
and libname
and isdir(join(getenv("GRASS_ADDON_BASE"), "etc", modname, libname))
):
path = join(getenv("GRASS_ADDON_BASE"), "etc", modname)
elif getenv("GRASS_ADDON_BASE") and isdir(
join(getenv("GRASS_ADDON_BASE"), "etc", modname)
) or (
getenv("GRASS_ADDON_BASE")
and isdir(join(getenv("GRASS_ADDON_BASE"), "etc", modname))
):
path = join(getenv("GRASS_ADDON_BASE"), "etc", modname)
elif getenv("GRASS_ADDON_BASE") and isdir(
Expand Down
20 changes: 5 additions & 15 deletions python/grass/temporal/temporal_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,15 +1275,9 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True):
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":
self.msgr.fatal(
_(
"Wrong temporal type of space time dataset "
"<%s> <%s> time is required"
)
% (id_input, self.temporaltype)
)
elif map_i.is_time_relative() and self.temporaltype == "absolute":
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 "
Expand All @@ -1299,13 +1293,9 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True):
maplist = input
# Create map_value as empty list item.
for map_i in maplist:
if "map_value" not in dir(map_i):
if ("map_value" not in dir(map_i)) or clear:
map_i.map_value = []
elif clear:
map_i.map_value = []
if "condition_value" not in dir(map_i):
map_i.condition_value = []
elif clear:
if ("condition_value" not in dir(map_i)) or clear:
map_i.condition_value = []
else:
self.msgr.fatal(_("Wrong type of input " + str(input)))
Expand Down
14 changes: 6 additions & 8 deletions utils/gitlog2changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@
dateFound = True
except Exception as e:
print(f"Could not parse dateList = '{line}'. Error: {e!s}")
# The Fossil-IDs are ignored:
elif line.startswith((" Fossil-ID:", " [[SVN:")):
continue
# The svn-id lines are ignored
elif " git-svn-id:" in line:
continue
# The sign off line is ignored too
elif "Signed-off-by" in line:
# The Fossil-IDs, svn-id, ad sign off lines are ignored:
elif (
line.startswith((" Fossil-ID:", " [[SVN:"))
or " git-svn-id:" in line
or "Signed-off-by" in line
):
continue
# Extract the actual commit message for this commit
elif authorFound & dateFound & messageFound is False:
Expand Down

0 comments on commit 70f3599

Please sign in to comment.