Skip to content

Commit

Permalink
CI(deps): Update ruff to v0.5.7 (OSGeo#4156)
Browse files Browse the repository at this point in the history
* CI(deps): Update ruff to v0.5.7

* Fix new RUF031 rule violations (incorrectly-parenthesized-tuple-in-subscript)

* Fix new ruff errors for C409: Unnecessary list comprehension passed to `tuple()` (rewrite as a generator)

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Edouard Choinière <[email protected]>
  • Loading branch information
renovate[bot] and echoix authored Aug 13, 2024
1 parent 8fa7eb8 commit 0fb6611
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# renovate: datasource=pypi depName=bandit
BANDIT_VERSION: "1.7.9"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.5.6"
RUFF_VERSION: "0.5.7"

runs-on: ${{ matrix.os }}
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.6
rev: v0.5.7
hooks:
# Run the linter.
- id: ruff
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/timeline/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,11 @@ def AddDataset(self, type_, yrange, xranges, datasetName):
if type_ == "bar":
self.data[yrange] = {"name": datasetName}
for i, (start, end) in enumerate(xranges):
self.data[yrange][(start, end)] = i
self.data[yrange][start, end] = i
elif type_ == "point":
self.data[(yrange, yrange)] = {"name": datasetName}
self.data[yrange, yrange] = {"name": datasetName}
for i, start in enumerate(xranges):
self.data[(yrange, yrange)][(start, start)] = i
self.data[yrange, yrange][start, start] = i

def GetInformation(self, x, y):
keys = None
Expand Down
4 changes: 2 additions & 2 deletions python/grass/imaging/images2gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,14 @@ def altersingle(self, alpha, i, b, g, r):

def geta(self, alpha, rad):
try:
return self.a_s[(alpha, rad)]
return self.a_s[alpha, rad]
except KeyError:
length = rad * 2 - 1
mid = length / 2
q = np.array(list(range(mid - 1, -1, -1)) + list(range(-1, mid)))
a = alpha * (rad * rad - q * q) / (rad * rad)
a[mid] = 0
self.a_s[(alpha, rad)] = a
self.a_s[alpha, rad] = a
return a

def alterneigh(self, alpha, rad, i, b, g, r):
Expand Down
6 changes: 3 additions & 3 deletions python/grass/pygrass/raster/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


_CELL = ("int", "intp", "int8", "int16", "int32", "int64")
CELL = tuple([getattr(np, attr) for attr in _CELL if hasattr(np, attr)])
CELL = tuple(getattr(np, attr) for attr in _CELL if hasattr(np, attr))
_FCELL = "float", "float16", "float32"
FCELL = tuple([getattr(np, attr) for attr in _FCELL if hasattr(np, attr)])
FCELL = tuple(getattr(np, attr) for attr in _FCELL if hasattr(np, attr))
_DCELL = "float64", "float128"
DCELL = tuple([getattr(np, attr) for attr in _DCELL if hasattr(np, attr)])
DCELL = tuple(getattr(np, attr) for attr in _DCELL if hasattr(np, attr))


class Buffer(np.ndarray):
Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/raster/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __dict__(self):
diz = {}
for cat in self.__iter__():
label, min_cat, max_cat = cat
diz[(min_cat, max_cat)] = label
diz[min_cat, max_cat] = label
return diz

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/vector/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ def from_wkt(self, wkt):
if match:
self.reset()
for coord in match.groups()[0].strip().split(","):
self.append(tuple([float(e) for e in coord.split(" ")]))
self.append(tuple(float(e) for e in coord.split(" ")))
else:
return None

Expand Down
4 changes: 2 additions & 2 deletions python/grass/pygrass/vector/testsuite/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def test_getitem_slice(self):
"""Test that getitem handle correctly the slice starting from 1"""
vcoords = ((10.0, 6.0), (12.0, 6.0))
with VectorTopo(self.tmpname, mode="r") as vect:
coords = tuple([pnt.coords() for pnt in vect[:3]])
coords = tuple(pnt.coords() for pnt in vect[:3])
self.assertTupleEqual(vcoords, coords)
coords = tuple([pnt.coords() for pnt in vect[1:3]])
coords = tuple(pnt.coords() for pnt in vect[1:3])
self.assertTupleEqual(vcoords, coords)
self.vect.close()

Expand Down
2 changes: 1 addition & 1 deletion scripts/d.rast.leg/d.rast.leg.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def main():

# fixes trunk r64459
s = s.split(":")[1]
f = tuple([float(x) for x in s.split()])
f = tuple(float(x) for x in s.split())

gs.run_command("d.erase")
os.environ["GRASS_RENDER_FILE_READ"] = "TRUE"
Expand Down
2 changes: 1 addition & 1 deletion scripts/v.in.wfs/v.in.wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def main():
wfs_url += request_base

if options["name"]:
if tuple([int(x) for x in version_num.split(".")]) >= (2, 0, 0):
if tuple(int(x) for x in version_num.split(".")) >= (2, 0, 0):
wfs_url += "&TYPENAMES=" + options["name"]
else:
wfs_url += "&TYPENAME=" + options["name"]
Expand Down

0 comments on commit 0fb6611

Please sign in to comment.