Skip to content

Commit

Permalink
style: Fix non-augmented-assignment (PLR6104) (OSGeo#4134)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored and Mahesh1998 committed Sep 19, 2024
1 parent 4dde83c commit 0ad7f65
Show file tree
Hide file tree
Showing 48 changed files with 100 additions and 101 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,7 @@ def Populate(self, update=False):
str(self.table[column]["type"]),
int(self.table[column]["length"]),
)
i = i + 1
i += 1

self.SendSizeEvent()

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2903,7 +2903,7 @@ def _draw(self, delay):
coords = self._getCoords()
if coords is not None:
for i in range(len(coords) // 2):
i = i * 2
i *= 2
self.pointsToDraw.AddItem(coords=(coords[i], coords[i + 1]))

self._giface.updateMap.emit(render=False, renderVector=False, delay=delay)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ def OnKeyPressed(self, event):

# move through command history list index values
if event.GetKeyCode() == wx.WXK_UP:
self.cmdindex = self.cmdindex - 1
self.cmdindex -= 1
if event.GetKeyCode() == wx.WXK_DOWN:
self.cmdindex = self.cmdindex + 1
self.cmdindex += 1
self.cmdindex = max(self.cmdindex, 0)
self.cmdindex = min(self.cmdindex, len(self.cmdbuffer) - 1)

Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/gui_core/pystc.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@ def FoldAll(self):
if expanding:
self.SetFoldExpanded(lineNum, True)
lineNum = self.Expand(lineNum, True)
lineNum = lineNum - 1
lineNum -= 1
else:
lastChild = self.GetLastChild(lineNum, -1)
self.SetFoldExpanded(lineNum, False)

if lastChild > lineNum:
self.HideLines(lineNum + 1, lastChild)

lineNum = lineNum + 1
lineNum += 1

def Expand(self, line, doExpand, force=False, visLevels=0, level=-1):
lastChild = self.GetLastChild(line, level)
line = line + 1
line += 1

while line <= lastChild:
if force:
Expand All @@ -392,6 +392,6 @@ def Expand(self, line, doExpand, force=False, visLevels=0, level=-1):
else:
line = self.Expand(line, False, force, visLevels - 1)
else:
line = line + 1
line += 1

return line
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ def OnLeftDown(self, event):
colLocs = [0]
loc = 0
for n in range(self.GetColumnCount()):
loc = loc + self.GetColumnWidth(n)
loc += self.GetColumnWidth(n)
colLocs.append(loc)

col = bisect(colLocs, x + self.GetScrollPos(wx.HORIZONTAL)) - 1
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/location_wizard/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ def __init__(
height += h
width = max(width, w)

height = height + 5
height += 5
height = min(height, 400)
width = width + 5
width += 5
width = min(width, 400)

#
Expand Down Expand Up @@ -746,12 +746,12 @@ def __init__(
def ClickTrans(self, event):
"""Get the number of the datum transform to use in g.proj"""
self.transnum = event.GetSelection()
self.transnum = self.transnum - 1
self.transnum -= 1

def GetTransform(self):
"""Get the number of the datum transform to use in g.proj"""
self.transnum = self.translist.GetSelection()
self.transnum = self.transnum - 1
self.transnum -= 1
return self.transnum


Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/location_wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ def OnEnterPage(self, event):
finishButton = wx.FindWindowById(wx.ID_FORWARD)
if ret == 0:
if datum != "":
projlabel = projlabel + "+datum=%s" % datum
projlabel += "+datum=%s" % datum
self.lproj4string.SetLabel(projlabel.replace(" +", os.linesep + "+"))
finishButton.Enable(True)
else:
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/mapdisp/gprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def OnPrintPage(self, page):
marginY = 10

# Add the margin to the graphic size
maxX = maxX + (2 * marginX)
maxY = maxY + (2 * marginY)
maxX += 2 * marginX
maxY += 2 * marginY

# Get the size of the DC in pixels
(w, h) = dc.GetSizeTuple()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapdisp/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _toolbarData(self):
),
)
if self.parent.IsDockable():
data = data + (
data += (
(
("docking", BaseIcons["docking"].label),
BaseIcons["docking"],
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapwin/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def MeasureDist(self, beginpt, endpt):
# the mathematical theta convention (CCW from +x axis)
# angle = 90 - angle
if angle < 0:
angle = 360 + angle
angle += 360

mstring = "%s = %s %s\n%s = %s %s\n%s = %d %s\n%s" % (
_("segment"),
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/nviz/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ def ComputeMxMy(self, x, y):
else:
my = 0.0

mx = mx / (1.0 - dx)
my = my / (1.0 - dy)
mx /= 1.0 - dx
my /= 1.0 - dy

# Quadratic seems smoother
mx *= abs(mx)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/nviz/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5860,8 +5860,8 @@ def Draw(self, pos, scale=False):
w, h = self.GetClientSize()
x, y = pos
if scale:
x = x * w
y = y * h
x *= w
y *= h
self.pdc.Clear()
self.pdc.BeginDrawing()
self.pdc.DrawLine(w // 2, h // 2, int(x), int(y))
Expand Down
14 changes: 7 additions & 7 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def getFile(self, wildcard):
filename = dlg.GetPath()
suffix = suffix[dlg.GetFilterIndex()]
if not os.path.splitext(filename)[1]:
filename = filename + suffix
filename += suffix
elif suffix not in {os.path.splitext(filename)[1], ""}:
filename = os.path.splitext(filename)[0] + suffix

Expand Down Expand Up @@ -1509,8 +1509,8 @@ def SetPage(self):

if self.currScale is None:
self.currScale = min(cW / pW, cH / pH)
pW = pW * self.currScale
pH = pH * self.currScale
pW *= self.currScale
pH *= self.currScale

x = cW / 2 - pW / 2
y = cH / 2 - pH / 2
Expand Down Expand Up @@ -2257,10 +2257,10 @@ def Zoom(self, zoomFactor, view):
"""Zoom to specified region, scroll view, redraw"""
if not self.currScale:
return
self.currScale = self.currScale * zoomFactor
self.currScale *= zoomFactor

if self.currScale > 10 or self.currScale < 0.1:
self.currScale = self.currScale / zoomFactor
self.currScale /= zoomFactor
return
if not self.preview:
# redraw paper
Expand Down Expand Up @@ -2606,8 +2606,8 @@ def ImageRect(self):
iW, iH = img.GetWidth(), img.GetHeight()

self.currScale = min(float(cW) / iW, float(cH) / iH)
iW = iW * self.currScale
iH = iH * self.currScale
iW *= self.currScale
iH *= self.currScale
x = cW / 2 - iW / 2
y = cH / 2 - iH / 2
return Rect(int(x), int(y), int(iW), int(iH))
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/rlisetup/sampling_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def writeArea(self, coords, rasterName):

catbuf = "=%d a\n" % self.catId
polyfile.write(catbuf)
self.catId = self.catId + 1
self.catId += 1

polyfile.close()
region_settings = grass.parse_command("g.region", flags="p", delimiter=":")
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/rlisetup/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ def afterRegionDrawn(self, marea):
if marea:
self.parent.msAreaList.append(marea)

self.regioncount = self.regioncount + 1
self.regioncount += 1
numregions = int(self.parent.samplingareapage.numregions)

if self.regioncount > numregions:
Expand Down Expand Up @@ -1715,7 +1715,7 @@ def SampleFrameChanged(self, region):
# region = self.GetSampleUnitRegion()
if region:
self.parent.msAreaList.append(region)
self.regioncount = self.regioncount + 1
self.regioncount += 1

drawtype = self.parent.drawunits.drawtype
if self.regioncount > self.numregions:
Expand Down Expand Up @@ -1813,7 +1813,7 @@ def __init__(self, wizard, parent):

def afterRegionDrawn(self):
"""Function to update the title and the number of selected area"""
self.areascount = self.areascount + 1
self.areascount += 1
if self.areascount == self.areanum:
wx.FindWindowById(wx.ID_FORWARD).Enable(True)
self.areaOK.Enable(False)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/vdigit/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def Populate(self, cats, update=False):
self.SetItem(index, 1, str(cat))
self.SetItemData(index, i)
itemData[i] = (str(layer), str(cat))
i = i + 1
i += 1

if not update:
self.SetColumnWidth(0, 100)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/web_services/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def _requestPage(self):

style = wx.TR_DEFAULT_STYLE | wx.TR_HAS_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT
if self.drv_props["req_multiple_layers"]:
style = style | wx.TR_MULTIPLE
style |= wx.TR_MULTIPLE
if "WMS" not in self.ws:
style = style | wx.TR_HIDE_ROOT
style |= wx.TR_HIDE_ROOT

self.list = LayersList(
parent=self.req_page_panel, web_service=self.ws, style=style
Expand Down
8 changes: 4 additions & 4 deletions imagery/i.atcorr/create_iwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ def write_cpp(bands, values, sensor, folder):
# Get minimum wavelength with spectral response
c = maxresponse_idx
while c > 0 and fi[c - 1] > rthresh:
c = c - 1
c -= 1
min_wavelength = np.ceil(li[0] * 1000 + (2.5 * c))
# Get maximum wavelength with spectral response
c = maxresponse_idx
while c < len(fi) - 1 and fi[c + 1] > rthresh:
c = c + 1
c += 1
max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
print(" %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength))

Expand All @@ -239,12 +239,12 @@ def write_cpp(bands, values, sensor, folder):
# Get minimum wavelength with spectral response
c = maxresponse_idx
while c > 0 and fi[c - 1] > rthresh:
c = c - 1
c -= 1
min_wavelength = np.ceil(li[0] * 1000 + (2.5 * c))
# Get maximum wavelength with spectral response
c = maxresponse_idx
while c < len(fi) - 1 and fi[c + 1] > rthresh:
c = c + 1
c += 1
max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
print(" %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength))

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ ignore = [
"PLR1704", # redefined-argument-from-local
"PLR1733", # unnecessary-dict-index-lookup
"PLR2004", # magic-value-comparison
"PLR6104", # non-augmented-assignment
"PLR6201", # literal-membership
"PLR6301", # no-self-use
"PLW0406", # import-self
Expand Down
2 changes: 1 addition & 1 deletion python/grass/grassdb/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def resolve_mapset_path(path, location=None, mapset=None) -> MapsetPath:
from grass.grassdb.checks import is_mapset_valid

if not is_mapset_valid(path) and is_mapset_valid(path / default_mapset):
path = path / default_mapset
path /= default_mapset
parts = path.parts
if len(parts) < 3:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion python/grass/gunittest/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def keyvalue_to_text(keyvalue, sep="=", vsep="\n", isep=",", last_vertical=None)
items.append("{key}{sep}{value}".format(key=key, sep=sep, value=value))
text = vsep.join(items)
if last_vertical:
text = text + vsep
text += vsep
return text


Expand Down
2 changes: 1 addition & 1 deletion python/grass/imaging/images2gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def writeGifToFile(self, fp, images, durations, loops, xys, disposes):
fp.write(d)

# Prepare for next round
frames = frames + 1
frames += 1

fp.write(";") # end gif
return frames
Expand Down
11 changes: 6 additions & 5 deletions python/grass/imaging/images2swf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
of a watermark in the upper left corner.
"""
from __future__ import annotations

import os
import zlib
Expand Down Expand Up @@ -224,7 +225,7 @@ def intToUint8(i):
return int(i).to_bytes(1, "little")


def intToBits(i, n=None):
def intToBits(i: int, n: int | None = None) -> BitArray:
"""convert int to a string of bits (0's and 1's in a string),
pad to n elements. Convert back using int(ss,2)."""
ii = i
Expand All @@ -233,7 +234,7 @@ def intToBits(i, n=None):
bb = BitArray()
while ii > 0:
bb += str(ii % 2)
ii = ii >> 1
ii >>= 1
bb.Reverse()

# justify
Expand Down Expand Up @@ -295,7 +296,7 @@ def getTypeAndLen(bb):
return type, L, L2


def signedIntToBits(i, n=None):
def signedIntToBits(i: int, n: int | None = None) -> BitArray:
"""convert signed int to a string of bits (0's and 1's in a string),
pad to n elements. Negative numbers are stored in 2's complement bit
patterns, thus positive numbers always start with a 0.
Expand All @@ -311,7 +312,7 @@ def signedIntToBits(i, n=None):
bb = BitArray()
while ii > 0:
bb += str(ii % 2)
ii = ii >> 1
ii >>= 1
bb.Reverse()

# justify
Expand Down Expand Up @@ -489,7 +490,7 @@ def ProcessTag(self):
for i in range(3):
clr = self.rgb[i]
if isinstance(clr, float):
clr = clr * 255
clr *= 255
bb += intToUint8(clr)
self.bytes = bb

Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/modules/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def define_mapset_inputs(self):
if inm.type in {"raster", "vector"} and inm.value:
if "@" not in inm.value:
mset = get_mapset_raster(inm.value)
inm.value = inm.value + "@%s" % mset
inm.value += "@%s" % mset

def run(self, patch=True, clean=True):
"""Run the GRASS command
Expand Down
Loading

0 comments on commit 0ad7f65

Please sign in to comment.