Skip to content

Commit

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

* style: Solve root-logger-call (LOG015)

Ruff rule: https://docs.astral.sh/ruff/rules/root-logger-call/

This rule is newly detected by ruff

* style: Trim trailing whitespace for pre-commit

---------

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 Nov 16, 2024
1 parent 6731a35 commit d558406
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 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.10"
# renovate: datasource=pypi depName=ruff
RUFF_VERSION: "0.7.3"
RUFF_VERSION: "0.7.4"

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.7.3
rev: v0.7.4
hooks:
# Run the linter.
- id: ruff
Expand Down
19 changes: 12 additions & 7 deletions python/grass/pygrass/rpc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
from multiprocessing.connection import Connection
from multiprocessing.synchronize import _LockLike


logger: logging.Logger = logging.getLogger(__name__)


###############################################################################


Expand Down Expand Up @@ -134,7 +138,7 @@ def thread_checker(self):

def start_server(self):
"""This function must be re-implemented in the subclasses"""
logging.debug("Start the libgis server")
logger.debug("Start the libgis server")

self.client_conn, self.server_conn = Pipe(True)
self.lock = Lock()
Expand All @@ -147,7 +151,7 @@ def check_server(self):

def _check_restart_server(self, caller="main thread") -> None:
"""Restart the server if it was terminated"""
logging.debug("Check libgis server restart")
logger.debug("Check libgis server restart")

with self.threadLock:
if self.server is not None and self.server.is_alive() is True:
Expand All @@ -159,17 +163,18 @@ def _check_restart_server(self, caller="main thread") -> None:
self.start_server()

if self.stopped is not True:
logging.warning(
"Needed to restart the libgis server, caller: {caller}",
caller=caller,
logger.warning(
"Needed to restart the libgis server, caller: %(caller)s",
{"caller": caller},
)

self.stopped = False

def safe_receive(self, message):
"""Receive the data and throw a FatalError exception in case the server
process was killed and the pipe was closed by the checker thread"""
logging.debug("Receive message: {message}")
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Receive message: %s", message)

try:
ret = self.client_conn.recv()
Expand All @@ -186,7 +191,7 @@ def stop(self):
This method should be called at exit using the package atexit
"""
logging.debug("Stop libgis server")
logger.debug("Stop libgis server")

self.stop_checker_thread()
if self.server is not None and self.server.is_alive():
Expand Down
48 changes: 26 additions & 22 deletions python/grass/temporal/c_libraries_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
from multiprocessing.connection import Connection
from multiprocessing.synchronize import _LockLike


logger = logging.getLogger(__name__)

###############################################################################


Expand Down Expand Up @@ -472,8 +475,9 @@ def _write_timestamp(lock: _LockLike, conn: Connection, data):
check = libgis.G_scan_timestamp(byref(ts), timestring)

if check != 1:
logging.error(
"Unable to convert the timestamp: {timestring}", timestring=timestring
logger.error(
"Unable to convert the timestamp: %(timestring)s",
{"timestring": timestring},
)
return -2

Expand Down Expand Up @@ -554,9 +558,9 @@ def _read_semantic_label(lock: _LockLike, conn: Connection, data):
if ret:
semantic_label = decode(ret)
else:
logging.error(
"Unable to read semantic label. Unsupported map type {maptype}",
maptype=maptype,
logger.error(
"Unable to read semantic label. Unsupported map type %(maptype)s",
{"maptype": maptype},
)
return -1
finally:
Expand Down Expand Up @@ -591,9 +595,9 @@ def _write_semantic_label(lock: _LockLike, conn: Connection, data):
raise ValueError(_("Invalid semantic label"))
libraster.Rast_write_semantic_label(name, semantic_label)
else:
logging.error(
"Unable to write semantic label. Unsupported map type {maptype}",
maptype=maptype,
logger.error(
"Unable to write semantic label. Unsupported map type %(maptype)s",
{"maptype": maptype},
)
return -2
finally:
Expand Down Expand Up @@ -625,9 +629,9 @@ def _remove_semantic_label(lock: _LockLike, conn: Connection, data):
if maptype == RPCDefs.TYPE_RASTER:
check = libgis.G_remove_misc("cell_misc", "semantic_label", name)
else:
logging.error(
"Unable to remove semantic label. Unsupported map type {maptype}",
maptype=maptype,
logger.error(
"Unable to remove semantic label. Unsupported map type %(maptype)s",
{"maptype": maptype},
)
return -2
finally:
Expand Down Expand Up @@ -743,11 +747,11 @@ def _read_raster_info(name, mapset):
libraster.Rast_init_fp_range(byref(range))
ret = libraster.Rast_read_fp_range(name, mapset, byref(range))
if ret < 0:
logging.warning(_("Unable to read range file"))
logger.warning(_("Unable to read range file"))
kvp["min"] = None
kvp["max"] = None
elif ret == 2:
logging.info(_("Raster range file is empty"))
logger.info(_("Raster range file is empty"))
kvp["min"] = None
kvp["max"] = None
else:
Expand All @@ -761,11 +765,11 @@ def _read_raster_info(name, mapset):
libraster.Rast_init_range(byref(range))
ret = libraster.Rast_read_range(name, mapset, byref(range))
if ret < 0:
logging.warning(_("Unable to read range file"))
logger.warning(_("Unable to read range file"))
kvp["min"] = None
kvp["max"] = None
elif ret == 2:
logging.info(_("Raster range file is empty"))
logger.info(_("Raster range file is empty"))
kvp["min"] = None
kvp["max"] = None
else:
Expand Down Expand Up @@ -831,7 +835,7 @@ def _read_raster3d_info(name, mapset):
)

if not g3map:
logging.error(_("Unable to open 3D raster map <%s>"), (name))
logger.error(_("Unable to open 3D raster map <%s>"), name)
return None

maptype = libraster3d.Rast3d_file_type_map(g3map)
Expand All @@ -846,7 +850,7 @@ def _read_raster3d_info(name, mapset):
max = libgis.DCELL()
ret = libraster3d.Rast3d_range_load(g3map)
if not ret:
logging.error(_("Unable to load range of 3D raster map <%s>"), (name))
logger.error(_("Unable to load range of 3D raster map <%s>"), name)
return None
libraster3d.Rast3d_range_min_max(g3map, byref(min), byref(max))

Expand All @@ -860,7 +864,7 @@ def _read_raster3d_info(name, mapset):
kvp["max"] = float(max.value)

if not libraster3d.Rast3d_close(g3map):
logging.error(_("Unable to close 3D raster map <%s>"), (name))
logger.error(_("Unable to close 3D raster map <%s>"), name)
return None

return kvp
Expand Down Expand Up @@ -902,9 +906,9 @@ def _read_vector_info(name, mapset):
libvector.Vect_set_open_level(1) # no topology
with_topo = False
if libvector.Vect_open_old2(byref(Map), name, mapset, "1") < 1:
logging.error(
logger.error(
_("Unable to open vector map <%s>"),
(libvector.Vect_get_full_name(byref(Map))),
libvector.Vect_get_full_name(byref(Map)),
)
return None

Expand Down Expand Up @@ -1026,7 +1030,7 @@ def _read_raster_history(name, mapset):
hist = libraster.History()
ret = libraster.Rast_read_history(name, mapset, byref(hist))
if ret < 0:
logging.warning(_("Unable to read history file"))
logger.warning(_("Unable to read history file"))
return None
kvp["creation_time"] = decode(
libraster.Rast_get_history(byref(hist), libraster.HIST_MAPID)
Expand Down Expand Up @@ -1063,7 +1067,7 @@ def _read_raster3d_history(name, mapset):
hist = libraster.History()
ret = libraster3d.Rast3d_read_history(name, mapset, byref(hist))
if ret < 0:
logging.warning(_("Unable to read history file"))
logger.warning(_("Unable to read history file"))
return None
kvp["creation_time"] = decode(
libraster.Rast_get_history(byref(hist), libraster3d.HIST_MAPID)
Expand Down
8 changes: 4 additions & 4 deletions vector/v.rectify/v.rectify.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ <h3>Coordinate transformation and RMSE</h3>
<p>The desired order of transformation (1, 2, or 3) is selected with the
<b>order</b> option.

If the <b>-r</b> flag is given, <em>v.rectify</em> will calculate the
If the <b>-r</b> flag is given, <em>v.rectify</em> will calculate the
Root Mean Square Error (RMSE) and print out statistics in tabular format.
The last row gives a summary with the first column holding the number of
active points, followed by average deviations for each dimension and both
forward and backward transformation and finally forward and backward
The last row gives a summary with the first column holding the number of
active points, followed by average deviations for each dimension and both
forward and backward transformation and finally forward and backward
overall RMSE.

<h4>2D linear affine transformation (1st order transformation)</h4>
Expand Down

0 comments on commit d558406

Please sign in to comment.