Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI(deps): Update ruff to v0.8.2 #4804

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# renovate: datasource=pypi depName=bandit
BANDIT_VERSION: "1.8.0"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.8.1"
RUFF_VERSION: "0.8.2"

runs-on: ${{ matrix.os }}
permissions:
Expand Down Expand Up @@ -146,7 +146,7 @@
- name: Set number of cores for compilation
run: |
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV

Check warning on line 149 in .github/workflows/python-code-quality.yml

View workflow job for this annotation

GitHub Actions / Python Code Quality Checks (ubuntu-22.04)

Temporarily downgraded pytest-pylint and pytest to allow merging other PRs. The errors reported with a newer version seem legitimite and should be fixed (2023-10-18, see https://github.com/OSGeo/grass/pull/3205) (2024-01-28, see https://github.com/OSGeo/grass/issues/3380)
- uses: rui314/setup-mold@b015f7e3f2938ad3a5ed6e5111a8c6c7c1d6db6e # v1
- name: Build
run: .github/workflows/build_${{ matrix.os }}.sh $HOME/install
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.8.1
rev: v0.8.2
hooks:
# Run the linter.
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions display/d.mon/render_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def adjust_region(width, height):

region["nsres"] = mapheight / height
region["ewres"] = mapwidth / width
region["rows"] = int(round(mapheight / region["nsres"]))
region["cols"] = int(round(mapwidth / region["ewres"]))
region["rows"] = round(mapheight / region["nsres"])
region["cols"] = round(mapwidth / region["ewres"])
region["cells"] = region["rows"] * region["cols"]

kwdata = [
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,9 +1409,9 @@ def DeleteLayer(self, layer, overlay=False):
"""
Debug.msg(3, "Map.DeleteLayer(): name=%s" % layer.name)

_list = self.overlays if overlay else self.layers
list_ = self.overlays if overlay else self.layers

if layer in _list:
if layer in list_:
if layer.mapfile:
base, mapfile = os.path.split(layer.mapfile)
tempbase = mapfile.split(".")[0]
Expand All @@ -1428,7 +1428,7 @@ def DeleteLayer(self, layer, overlay=False):
if os.path.isfile(layer._legrow):
os.remove(layer._legrow)

_list.remove(layer)
list_.remove(layer)

self.layerRemoved.emit(layer=layer)
return layer
Expand Down Expand Up @@ -1563,10 +1563,10 @@ def GetLayerIndex(self, layer, overlay=False):
:return: layer index
:return: -1 if layer not found
"""
_list = self.overlays if overlay else self.layers
list_ = self.overlays if overlay else self.layers

if layer in _list:
return _list.index(layer)
if layer in list_:
return list_.index(layer)

return -1

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def formatDist(distance, mapunits):
outdistance = round(distance / divisor, 1)
elif (distance / divisor) > 0.0:
outdistance = round(
distance / divisor, int(math.ceil(3 - math.log10(distance / divisor)))
distance / divisor, math.ceil(3 - math.log10(distance / divisor))
)
else:
outdistance = float(distance / divisor)
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 @@ -437,7 +437,7 @@ def __ll_parts(value, reverse=False, precision=3):
if value == 0.0:
return "%s%.*f" % ("00:00:0", precision, 0.0)

d = int(int(value))
d = int(value)
m = int((value - d) * 60)
s = ((value - d) * 60 - m) * 60
if m < 0:
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/iscatt/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ def SetBusy(self, busy):

def CursorPlotMove(self, x, y, scatt_id):
try:
x = int(round(x))
y = int(round(y))
x = round(x)
y = round(y)
coords = True
except TypeError:
coords = False
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def Plot(self, cats_order, scatts, ellipses, styles):
img = imshow(
self.axes,
merged_img,
extent=[int(ceil(x)) for x in self.full_extend],
extent=[ceil(x) for x in self.full_extend],
origin="lower",
interpolation="nearest",
aspect="equal",
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/psmap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,6 @@ def BBoxAfterRotation(w, h, angle):
x_min = x
x_max = x + wct - hst

width = int(ceil(abs(x_max) + abs(x_min)))
height = int(ceil(abs(y_max) + abs(y_min)))
width = ceil(abs(x_max) + abs(x_min))
height = ceil(abs(y_max) + abs(y_min))
return width, height
4 changes: 2 additions & 2 deletions gui/wxpython/vdigit/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@ def UpdateSettings(self):
tree.SetLayerInfo(item, key="vdigit", value={"geomAttr": {}})

if checked: # enable
_type = key if key == "area" else "length"
unitsKey = Units.GetUnitsKey(_type, unitsIdx)
type_ = key if key == "area" else "length"
unitsKey = Units.GetUnitsKey(type_, unitsIdx)
tree.GetLayerInfo(item, key="vdigit")["geomAttr"][key] = {
"column": column,
"units": unitsKey,
Expand Down
8 changes: 4 additions & 4 deletions python/grass/pygrass/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_fatal_error(self, message: str) -> None:


def get_msgr(
_instance=[
instance=[
None,
],
*args,
Expand All @@ -357,9 +357,9 @@ def get_msgr(
>>> msgr0 is msgr2
False
"""
if not _instance[0]:
_instance[0] = Messenger(*args, **kwargs)
return _instance[0]
if not instance[0]:
instance[0] = Messenger(*args, **kwargs)
return instance[0]


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions python/grass/script/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ def set_path(modulename, dirname=None, path="."):
import sys

# TODO: why dirname is checked first - the logic should be revised
_pathlib = None
pathlib_ = None
if dirname:
_pathlib = os.path.join(path, dirname)
if _pathlib and os.path.exists(_pathlib):
pathlib_ = os.path.join(path, dirname)
if pathlib_ and os.path.exists(pathlib_):
# we are running the script from the script directory, therefore
# we add the path to sys.path to reach the directory (dirname)
sys.path.append(os.path.abspath(path))
Expand Down
22 changes: 11 additions & 11 deletions python/grass/temporal/gui_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def tlist_grouped(type, group_type: bool = False, dbif=None):
:return: directory of mapsets/elements
"""
result = {}
_type = type
type_ = type
dbif, connection_state_changed = init_dbif(dbif)

mapset = None
types = ["strds", "str3ds", "stvds"] if _type == "stds" else [_type]
for _type in types:
types = ["strds", "str3ds", "stvds"] if type_ == "stds" else [type_]
for type_ in types:
try:
tlist_result = tlist(type=_type, dbif=dbif)
tlist_result = tlist(type=type_, dbif=dbif)
except gs.ScriptError as e:
gs.warning(e)
continue
Expand All @@ -63,10 +63,10 @@ def tlist_grouped(type, group_type: bool = False, dbif=None):
result[mapset] = []

if group_type:
if _type in result[mapset]:
result[mapset][_type].append(name)
if type_ in result[mapset]:
result[mapset][type_].append(name)
else:
result[mapset][_type] = [
result[mapset][type_] = [
name,
]
else:
Expand All @@ -88,20 +88,20 @@ def tlist(type, dbif=None):

:return: a list of space time dataset ids
"""
_type = type
type_ = type
id = None
sp = dataset_factory(_type, id)
sp = dataset_factory(type_, id)
dbif, connection_state_changed = init_dbif(dbif)

mapsets = get_available_temporal_mapsets()

output = []
temporal_type = ["absolute", "relative"]
for _type in temporal_type:
for type_ in temporal_type:
# For each available mapset
for mapset in mapsets.keys():
# Table name
if _type == "absolute":
if type_ == "absolute":
table = sp.get_type() + "_view_abs_time"
else:
table = sp.get_type() + "_view_rel_time"
Expand Down
4 changes: 2 additions & 2 deletions python/grass/temporal/spatio_temporal_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ def __getitem__(self, index):
def __len__(self) -> int:
return len(self._store)

def __contains__(self, _map) -> bool:
return _map in self._store.values()
def __contains__(self, map_) -> bool:
return map_ in self._store.values()


###############################################################################
Expand Down
Loading
Loading