Skip to content

Commit

Permalink
style: Fix unnecessary-range-start (PIE808)
Browse files Browse the repository at this point in the history
As 0 is the default start value, it can be safely omitted.

Ruff rule: https://docs.astral.sh/ruff/rules/unnecessary-range-start/
  • Loading branch information
echoix committed Oct 5, 2024
1 parent a16a02f commit 379ac4a
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion general/g.remove/testsuite/test_g_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def tearDownClass(cls):

def test_remove_procedure(self):
"""Test that maps are removed only with -f"""
for i in range(0, 10):
for i in range(10):
rmapcalc("test_map_%i = 100" % i)
rmapcalc("test_two = 2")

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def __init__(self, lmgr, file):
file.write("{indent}</layout>\n".format(indent=" " * self.indent))

# list of displays
for page in range(0, self.lmgr.GetLayerNotebook().GetPageCount()):
for page in range(self.lmgr.GetLayerNotebook().GetPageCount()):
dispName = self.lmgr.GetLayerNotebook().GetPageText(page)
mapTree = self.lmgr.GetLayerNotebook().GetPage(page).maptree
region = mapTree.GetMap().GetCurrentRegion()
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 @@ -2745,7 +2745,7 @@ def __init__(
if elements:
values = []
valuesDesc = []
for idx in range(0, len(self.values)):
for idx in range(len(self.values)):
value = self.values[idx]
if value in elements:
values.append(value)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def RemoveFileFromHistory(self, file_index):

def RemoveNonExistentFiles(self):
"""Remove non existent files from the history"""
for i in reversed(range(0, self._filehistory.GetCount())):
for i in reversed(range(self._filehistory.GetCount())):
file = self._filehistory.GetHistoryFile(index=i)
if not os.path.exists(file):
self._filehistory.RemoveFileFromHistory(i=i)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/lmgr/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def GetMapDisplay(self, onlyCurrent=True):
return None
else: # -> return list of all mapdisplays
mlist = []
for idx in range(0, self.notebookLayers.GetPageCount()):
for idx in range(self.notebookLayers.GetPageCount()):
mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay())

return mlist
Expand Down Expand Up @@ -1906,7 +1906,7 @@ def _onMapDisplayStarting3dMode(self, mapDisplayPage):
"""Disables 3D mode for all map displays except for @p mapDisplay"""
# TODO: it should be disabled also for newly created map windows
# moreover mapdisp.Disable3dMode() does not work properly
for page in range(0, self.GetLayerNotebook().GetPageCount()):
for page in range(self.GetLayerNotebook().GetPageCount()):
mapdisp = self.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
if self.GetLayerNotebook().GetPage(page) != mapDisplayPage:
mapdisp.Disable3dMode()
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ def GetMapDisplay(self, onlyCurrent=True):
return None
else: # -> return list of all mapdisplays
mlist = []
for idx in range(0, self.notebookLayers.GetPageCount()):
for idx in range(self.notebookLayers.GetPageCount()):
mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay())

return mlist
Expand Down Expand Up @@ -2054,7 +2054,7 @@ def _onStarting3dMode(self, mapDisplayPage):
"""Disables 3D mode for all map displays except for @p mapDisplay"""
# TODO: it should be disabled also for newly created map windows
# moreover mapdisp.Disable3dMode() does not work properly
for page in range(0, self.GetLayerNotebook().GetPageCount()):
for page in range(self.GetLayerNotebook().GetPageCount()):
mapdisp = self.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
if self.GetLayerNotebook().GetPage(page) != mapDisplayPage:
mapdisp.Disable3dMode()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapdisp/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def DisableStatusbarItemsByClass(self, itemClasses):
:param itemClasses list of classes of items to be disabled
"""
for itemClass in itemClasses:
for i in range(0, len(self.statusbarItems.values())):
for i in range(len(self.statusbarItems.values())):
item = list(self.statusbarItems.values())[i]
if item.__class__ == itemClass:
self.disabledItems[i] = item
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/vdigit/wxdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def SetSelected(self, ids, layer=-1):

found = False
cats = self.poCats.contents
for i in range(0, cats.n_cats):
for i in range(cats.n_cats):
for cat in self.selected["cats"]:
if cats.cat[i] == cat:
found = True
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ ignore = [
"PERF402", # manual-list-copy
"PERF403", # manual-dict-comprehension
"PIE794", # duplicate-class-field-definition
"PIE808", # unnecessary-range-start
"PLC0415", # import-outside-top-level
"PLC1901", # compare-to-empty-string
"PLC2701", # import-private-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_without_context_manager(xy_session):
def test_multiple_sequential_with_context_manager(xy_session):
"""Session creates, starts, and finishes"""
session_file = xy_session.env["GISRC"]
for i in range(0, 5):
for i in range(5):
with experimental.TemporaryMapsetSession(env=xy_session.env) as session:
assert session.active
gs.run_command("g.region", flags="p", env=session.env)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_multiple_parallel_without_context_manager(xy_session):
"""Session creates, starts, and finishes"""
session_file = xy_session.env["GISRC"]
sessions = []
for i in range(0, 5):
for i in range(5):
session_file = xy_session.env["GISRC"]
session = experimental.TemporaryMapsetSession(env=xy_session.env)
gs.run_command("g.region", flags="p", env=session.env)
Expand Down
4 changes: 2 additions & 2 deletions scripts/d.polar/d.polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def plot_dgraph():
50 * (1 + ring * math.sin(math.radians(i))),
50 * (1 + ring * math.cos(math.radians(i))),
)
for i in range(0, 361)
for i in range(361)
]

# trend vector
Expand Down Expand Up @@ -512,7 +512,7 @@ def main():
outercircle = []
outercircle.append('"All Data incl. NULLs')
scale = 1.0 * totalnumber / totalvalidnumber * maxradius
for i in range(0, 361):
for i in range(361):
a = math.radians(i)
x = math.cos(a) * scale
y = math.sin(a) * scale
Expand Down
2 changes: 1 addition & 1 deletion scripts/i.oif/i.oif.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def oifcalc(sdev, corr, k1, k2, k3):

def perms(bands):
n = len(bands)
for i in range(0, n - 2):
for i in range(n - 2):
for j in range(i + 1, n - 1):
for k in range(j + 1, n):
yield (bands[i], bands[j], bands[k])
Expand Down
2 changes: 1 addition & 1 deletion scripts/i.pansharpen/i.pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def matchhist(original, target, matched):
0 # cumulative total of cells for sum of current and all lower grey values
)

for n in range(0, 256):
for n in range(256):
if str(n) in stats_dict:
num_cells = stats_dict[str(n)]
else:
Expand Down
2 changes: 1 addition & 1 deletion scripts/i.tasscap/i.tasscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def main():

# assign "Data Description" field in all four component maps
num_comp = len(parms[satellites.index(satellite)])
for i in range(0, num_comp):
for i in range(num_comp):
comp = names[i]
gs.run_command(
"r.support",
Expand Down
2 changes: 1 addition & 1 deletion scripts/v.report/v.report.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def main():
cols = decode(line).rstrip("\r\n").split("|")
if catcol == -1:
ncols = len(cols)
for i in range(0, ncols):
for i in range(ncols):
if cols[i] == f["key"]:
catcol = i
break
Expand Down

0 comments on commit 379ac4a

Please sign in to comment.