Skip to content

Commit

Permalink
style: Fix yoda-conditions (SIM300) (OSGeo#4044)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Jul 13, 2024
1 parent b01a67d commit d690d0c
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def kill(self):
import win32api

handle = win32api.OpenProcess(1, 0, self.pid)
return 0 != win32api.TerminateProcess(handle, 0)
return win32api.TerminateProcess(handle, 0) != 0
else:
try:
os.kill(-self.pid, signal.SIGTERM) # kill whole group
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None, layerType=None):
if len(dcmd) < 1:
return mapname, False

if "d.grid" == dcmd[0]:
if dcmd[0] == "d.grid":
mapname = "grid"
elif "d.geodesic" in dcmd[0]:
mapname = "geodesic"
Expand Down
13 changes: 7 additions & 6 deletions gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,9 @@ def ExportAreas(self, vectorName, withTable):
% {"band": i + 1, "stat": statistic, "format": format}
)

if 0 != RunCommand(
"v.db.addtable", map=vectorName, columns=columns, parent=self
if (
RunCommand("v.db.addtable", map=vectorName, columns=columns, parent=self)
!= 0
):
wx.EndBusyCursor()
return False
Expand Down Expand Up @@ -1305,10 +1306,10 @@ def CheckInput(self, group, vector):
rasterInfo = gs.raster_info(groupLayers[0])

if (
regionBox.N > rasterInfo["north"]
or regionBox.S < rasterInfo["south"]
or regionBox.E > rasterInfo["east"]
or regionBox.W < rasterInfo["west"]
rasterInfo["north"] < regionBox.N
or rasterInfo["south"] > regionBox.S
or rasterInfo["east"] < regionBox.E
or rasterInfo["west"] > regionBox.W
):
GMessage(
parent=self,
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/lmgr/layertree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def OnCopyMap(self, event):
return

kwargs = {key: "%s,%s" % (lnameSrc, lnameDst)}
if 0 != RunCommand("g.copy", overwrite=True, **kwargs):
if RunCommand("g.copy", overwrite=True, **kwargs) != 0:
GError(_("Unable to make copy of <%s>") % lnameSrc, parent=self)
return

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/web_services/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def UpdateWidgetsByCmd(self, cmd):

if "bgcolor" in dcmd and self.params["bgcolor"]:
bgcolor = dcmd["bgcolor"].strip().lower()
if len(bgcolor) == 8 and "0x" == bgcolor[:2]:
if len(bgcolor) == 8 and bgcolor[:2] == "0x":
colour = "#" + bgcolor[2:]
self.params["bgcolor"].SetColour(colour)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ ignore = [
"SIM118", # in-dict-keys
"SIM201", # negate-equal-op
"SIM223", # expr-and-false
"SIM300", # yoda-conditions
"SIM401", # if-else-block-instead-of-dict-get
"SLF001", # private-member-access
"TRY002", # raise-vanilla-class
Expand Down
Loading

0 comments on commit d690d0c

Please sign in to comment.