diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index 5d845193938..7d4ed678d79 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -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 diff --git a/gui/wxpython/core/utils.py b/gui/wxpython/core/utils.py index 47977a1a27b..5e52fc0532d 100644 --- a/gui/wxpython/core/utils.py +++ b/gui/wxpython/core/utils.py @@ -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" diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index 3a8626a76ee..14c44aba5ea 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -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 @@ -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, diff --git a/gui/wxpython/lmgr/layertree.py b/gui/wxpython/lmgr/layertree.py index e935af8ce5d..38751e35b55 100644 --- a/gui/wxpython/lmgr/layertree.py +++ b/gui/wxpython/lmgr/layertree.py @@ -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 diff --git a/gui/wxpython/web_services/widgets.py b/gui/wxpython/web_services/widgets.py index 811b718a012..200d5521b70 100644 --- a/gui/wxpython/web_services/widgets.py +++ b/gui/wxpython/web_services/widgets.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 2ca0e33f163..50e9f651b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/python/grass/temporal/spatial_extent.py b/python/grass/temporal/spatial_extent.py index 3bf67b3d533..6c025fb7a40 100644 --- a/python/grass/temporal/spatial_extent.py +++ b/python/grass/temporal/spatial_extent.py @@ -183,11 +183,11 @@ def overlapping_2d(self, extent): # Adjust the east and west in case of LL projection if self.get_projection() == "LL": - while E < self.get_west(): + while self.get_west() > E: E += 360.0 W += 360.0 - while W > self.get_east(): + while self.get_east() < W: E -= 360.0 W -= 360.0 @@ -285,13 +285,13 @@ def intersect_2d(self, extent): nE = E nW = W - if W < eW: + if eW > W: nW = eW - if E > eE: + if eE < E: nE = eE - if N > eN: + if eN < N: nN = eN - if S < eS: + if eS > S: nS = eS return SpatialExtent( @@ -395,9 +395,9 @@ def intersect(self, extent): nT = T nB = B - if B < eB: + if eB > B: nB = eB - if T > eT: + if eT < T: nT = eT new.set_top(nT) @@ -449,13 +449,13 @@ def disjoint_union_2d(self, extent): nE = E nW = W - if W > eW: + if eW < W: nW = eW - if E < eE: + if eE > E: nE = eE - if N < eN: + if eN > N: nN = eN - if S > eS: + if eS < S: nS = eS return SpatialExtent( @@ -582,9 +582,9 @@ def disjoint_union(self, extent): nT = T nB = B - if B > eB: + if eB < B: nB = eB - if T < eT: + if eT > T: nT = eT new.set_top(nT) @@ -636,13 +636,13 @@ def is_in_2d(self, extent): eE -= 360.0 eW -= 360.0 - if W <= eW: + if eW >= W: return False - if E >= eE: + if eE <= E: return False - if N >= eN: + if eN <= N: return False - if S <= eS: + if eS >= S: return False return True @@ -678,9 +678,9 @@ def is_in(self, extent): T = self.get_top() B = self.get_bottom() - if B <= eB: + if eB >= B: return False - if T >= eT: + if eT <= T: return False return True @@ -776,13 +776,13 @@ def equivalent_2d(self, extent): eE -= 360.0 eW -= 360.0 - if W != eW: + if eW != W: return False - if E != eE: + if eE != E: return False - if N != eN: + if eN != N: return False - if S != eS: + if eS != S: return False return True @@ -819,9 +819,9 @@ def equivalent(self, extent): T = self.get_top() B = self.get_bottom() - if B != eB: + if eB != B: return False - if T != eT: + if eT != T: return False return True @@ -892,28 +892,28 @@ def cover_2d(self, extent): eW -= 360.0 # Edges of extent located outside of self are not allowed - if E <= eW: + if eW >= E: return False - if W >= eE: + if eE <= W: return False - if N <= eS: + if eS >= N: return False - if S >= eN: + if eN <= S: return False # First we check that at least one edge of extent meets an edge of self - if W != eW and E != eE and N != eN and S != eS: + if eW != W and eE != E and eN != N and eS != S: return False # We check that at least one edge of extent is located in self edge_count = 0 - if W < eW and E > eW: + if eW > W and eW < E: edge_count += 1 - if E > eE and W < eE: + if eE < E and eE > W: edge_count += 1 - if N > eN and S < eN: + if eN < N and eN > S: edge_count += 1 - if S < eS and N > eS: + if eS > S and eS < N: edge_count += 1 if edge_count == 0: @@ -974,40 +974,40 @@ def cover(self, extent): eW -= 360.0 # Edges of extent located outside of self are not allowed - if E <= eW: + if eW >= E: return False - if W >= eE: + if eE <= W: return False - if N <= eS: + if eS >= N: return False - if S >= eN: + if eN <= S: return False - if T <= eB: + if eB >= T: return False - if B >= eT: + if eT <= B: return False # First we check that at least one edge of extent meets an edge of self - if W != eW and E != eE and N != eN and S != eS and B != eB and T != eT: + if eW != W and eE != E and eN != N and eS != S and eB != B and eT != T: return False # We check that at least one edge of extent is located in self edge_count = 0 - if W < eW and E > eW: + if eW > W and eW < E: edge_count += 1 - if E > eE and W < eE: + if eE < E and eE > W: edge_count += 1 - if N > eN and S < eN: + if eN < N and eN > S: edge_count += 1 - if S < eS and N > eS: + if eS > S and eS < N: edge_count += 1 - if N > eN and S < eN: + if eN < N and eN > S: edge_count += 1 - if S < eS and N > eS: + if eS > S and eS < N: edge_count += 1 - if T > eT and B < eT: + if eT < T and eT > B: edge_count += 1 - if B < eB and T > eB: + if eB > B and eB < T: edge_count += 1 if edge_count == 0: @@ -1095,11 +1095,11 @@ def overlap_2d(self, extent): # Adjust the east and west in case of LL projection if self.get_projection() == "LL": - while E < self.get_west(): + while self.get_west() > E: E += 360.0 W += 360.0 - while W > self.get_east(): + while self.get_east() < W: E -= 360.0 W -= 360.0 @@ -1157,11 +1157,11 @@ def overlap(self, extent): # Adjust the east and west in case of LL projection if self.get_projection() == "LL": - while E < self.get_west(): + while self.get_west() > E: E += 360.0 W += 360.0 - while W > self.get_east(): + while self.get_east() < W: E -= 360.0 W -= 360.0 @@ -1242,16 +1242,16 @@ def meet_2d(self, extent): edge = None edge_count = 0 - if E == eW: + if eW == E: edge = "E" edge_count += 1 - if W == eE: + if eE == W: edge = "W" edge_count += 1 - if N == eS: + if eS == N: edge = "N" edge_count += 1 - if S == eN: + if eN == S: edge = "S" edge_count += 1 @@ -1261,11 +1261,11 @@ def meet_2d(self, extent): # Check boundaries of the faces if edge in {"E", "W"}: - if N < eS or S > eN: + if eS > N or eN < S: return False if edge in {"N", "S"}: - if E < eW or W > eE: + if eW > E or eE < W: return False return True @@ -1306,22 +1306,22 @@ def meet(self, extent): edge = None edge_count = 0 - if E == eW: + if eW == E: edge = "E" edge_count += 1 - if W == eE: + if eE == W: edge = "W" edge_count += 1 - if N == eS: + if eS == N: edge = "N" edge_count += 1 - if S == eN: + if eN == S: edge = "S" edge_count += 1 - if T == eB: + if eB == T: edge = "T" edge_count += 1 - if B == eT: + if eT == B: edge = "B" edge_count += 1 @@ -1331,21 +1331,21 @@ def meet(self, extent): # Check boundaries of the faces if edge in {"E", "W"}: - if N < eS or S > eN: + if eS > N or eN < S: return False - if T < eB or B > eT: + if eB > T or eT < B: return False if edge in {"N", "S"}: - if E < eW or W > eE: + if eW > E or eE < W: return False - if T < eB or B > eT: + if eB > T or eT < B: return False if edge in {"T", "B"}: - if E < eW or W > eE: + if eW > E or eE < W: return False - if N < eS or S > eN: + if eS > N or eN < S: return False return True diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py index 4c64a9f9ff8..a944701f77a 100644 --- a/scripts/g.extension/g.extension.py +++ b/scripts/g.extension/g.extension.py @@ -2078,7 +2078,7 @@ def install_extension_std_platforms(name, source, url, branch): if not os.path.exists(os.path.join(gisbase, "include", "Make", "Module.make")): gs.fatal(_("Please install GRASS development package")) - if 0 != gs.call(make_cmd, stdout=outdev): + if gs.call(make_cmd, stdout=outdev) != 0: gs.fatal(_("Compilation failed, sorry. Please check above error messages.")) if flags["i"]: