Skip to content

Commit 6ac6f55

Browse files
🧑‍💻 pre-commit autoupdate (#944)
updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.12.2](astral-sh/ruff-pre-commit@v0.11.13...v0.12.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * 📌 Update `ruff` version --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <[email protected]>
1 parent 22dfa11 commit 6ac6f55

29 files changed

+102
-92
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
sudo apt update
3131
sudo apt-get install -y libopenjp2-7 libopenjp2-tools
3232
python -m pip install --upgrade pip
33-
python -m pip install ruff==0.11.13 pytest pytest-cov pytest-runner
33+
python -m pip install ruff==0.12.2 pytest pytest-cov pytest-runner
3434
pip install -r requirements/requirements.txt
3535
- name: Cache tiatoolbox static assets
3636
uses: actions/cache@v3

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repos:
6060
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst.
6161
- repo: https://github.com/astral-sh/ruff-pre-commit
6262
# Ruff version.
63-
rev: v0.11.13
63+
rev: v0.12.2
6464
hooks:
6565
- id: ruff
6666
args: [--fix, --exit-non-zero-on-fix]

benchmarks/annotation_store_alloc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def __exit__(self: memray, *args: object) -> None:
141141

142142
import numpy as np
143143
import psutil
144+
from shapely import affinity
144145
from shapely.geometry import Polygon
145146
from tqdm import tqdm
146147

@@ -188,8 +189,6 @@ def cell_polygon(
188189
round_coords (bool): Round coordinates to integers. Defaults to False.
189190
190191
"""
191-
from shapely import affinity
192-
193192
rand_state = np.random.default_rng().__getstate__()
194193
rng = np.random.default_rng(seed)
195194
if repeat_first:

pre-commit/notebook_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def git_branch_name() -> str:
1515
"""Get the current branch name."""
1616
return (
17-
subprocess.check_output( # noqa: S603
17+
subprocess.check_output(
1818
["/usr/bin/git", "rev-parse", "--abbrev-ref", "HEAD"],
1919
)
2020
.decode()
@@ -45,7 +45,7 @@ def git_previous_commit_modified_paths() -> set[Path]:
4545
"""Get a set of file paths modified in the previous commit."""
4646
return {
4747
Path(p)
48-
for p in subprocess.check_output( # noqa: S603
48+
for p in subprocess.check_output(
4949
["/usr/bin/git", "diff", "--name-only", "HEAD~"],
5050
)
5151
.decode()

pre-commit/requirements_consistency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def parse_setup_py(file_path: Path) -> dict[str, Requirement]:
115115
pkg_resources.Requirement.
116116
"""
117117
mock_setup = {}
118-
import setuptools
118+
import setuptools # noqa: PLC0415
119119

120120
setuptools.setup = lambda **kw: mock_setup.update(kw)
121121
spec = importlib.util.spec_from_file_location("setup", str(file_path))

requirements/requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pytest>=7.2.0
1010
pytest-cov>=4.0.0
1111
pytest-runner>=6.0
1212
pytest-xdist[psutil]
13-
ruff==0.11.13 # This will be updated by pre-commit bot to latest version
13+
ruff==0.12.2 # This will be updated by pre-commit bot to latest version
1414
toml>=0.10.2
1515
twine>=4.0.1
1616
wheel>=0.37.1

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ def chdir() -> Callable:
589589
590590
"""
591591
try:
592-
from contextlib import chdir
592+
from contextlib import chdir # noqa: PLC0415
593593
except ImportError:
594-
from contextlib import AbstractContextManager
594+
from contextlib import AbstractContextManager # noqa: PLC0415
595595

596596
class chdir(AbstractContextManager): # noqa: N801
597597
"""Non thread-safe context manager to change the current working directory.

tests/test_init.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_set_root_dir(tmp_path: Path) -> None:
1616
"""Test for setting new root dir."""
1717
# skipcq
1818
importlib.reload(tiatoolbox)
19-
from tiatoolbox import rcParam
19+
from tiatoolbox import rcParam # noqa: PLC0415
2020

2121
old_root_dir = rcParam["TIATOOLBOX_HOME"]
2222
test_dir_path = tmp_path / "tmp_check"
@@ -27,7 +27,7 @@ def test_set_root_dir(tmp_path: Path) -> None:
2727
# reimport to see if it overwrites
2828
# silence Deep Source because this is an intentional check
2929
# skipcq
30-
from tiatoolbox import rcParam
30+
from tiatoolbox import rcParam # noqa: PLC0415
3131

3232
rcParam["TIATOOLBOX_HOME"].mkdir(parents=True)
3333
if not Path.exists(test_dir_path):
@@ -135,9 +135,9 @@ def test_duplicate_filter(caplog: pytest.LogCaptureFixture) -> None:
135135

136136
def test_lazy_import() -> None:
137137
"""Test lazy import for tiatoolbox."""
138-
import sys
138+
import sys # noqa: PLC0415
139139

140-
from tiatoolbox import _lazy_import
140+
from tiatoolbox import _lazy_import # noqa: PLC0415
141141

142142
assert "exceptions" not in sys.modules
143143

@@ -151,7 +151,7 @@ def test_lazy_import() -> None:
151151

152152
def test_lazy_import_module_not_found() -> None:
153153
"""'Test lazy import for ModuleNotFoundError."""
154-
from tiatoolbox import _lazy_import
154+
from tiatoolbox import _lazy_import # noqa: PLC0415
155155

156156
with pytest.raises(ModuleNotFoundError):
157157
_lazy_import(

tests/test_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import hashlib
6+
import json
67
import shutil
78
from pathlib import Path
89
from typing import TYPE_CHECKING, NoReturn
@@ -27,7 +28,10 @@
2728
from tiatoolbox.annotation.storage import DictionaryStore, SQLiteStore
2829
from tiatoolbox.enums import GeometryType
2930
from tiatoolbox.models.architecture import fetch_pretrained_weights
30-
from tiatoolbox.models.architecture.utils import compile_model
31+
from tiatoolbox.models.architecture.utils import (
32+
compile_model,
33+
is_torch_compile_compatible,
34+
)
3135
from tiatoolbox.utils import misc
3236
from tiatoolbox.utils.exceptions import FileNotSupportedError
3337
from tiatoolbox.utils.transforms import locsize2bounds
@@ -1348,8 +1352,6 @@ def test_select_device() -> None:
13481352
def test_save_as_json(tmp_path: Path) -> None:
13491353
"""Test save data to json."""
13501354
# This should be broken up into separate tests!
1351-
import json
1352-
13531355
# dict with nested dict, list, and np.array
13541356
key_dict = {
13551357
"a1": {"name": "John", "age": 23, "sex": "male"},
@@ -1860,8 +1862,6 @@ def test_torch_compile_disable() -> None:
18601862

18611863
def test_torch_compile_compatibility(caplog: pytest.LogCaptureFixture) -> None:
18621864
"""Test if torch-compile compatibility is checked correctly."""
1863-
from tiatoolbox.models.architecture.utils import is_torch_compile_compatible
1864-
18651865
is_torch_compile_compatible()
18661866
assert "torch.compile" in caplog.text
18671867

tiatoolbox/annotation/dsl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class SQLTriplet(SQLExpression):
217217

218218
def __init__(
219219
self: SQLExpression,
220-
lhs: SQLTriplet | str | SQLExpression | Number | bool | object,
220+
lhs: SQLTriplet | str | SQLExpression | Number | bool | object, # noqa: FBT001
221221
op: Callable | str | None = None,
222222
rhs: SQLTriplet | str | SQLExpression | Number | SQLNone | object | None = None,
223223
) -> None:
@@ -373,7 +373,7 @@ def json_contains(json_str: str, x: object) -> bool:
373373
return x in json.loads(json_str)
374374

375375

376-
def sql_is_none(x: SQLExpression | Number | str | bool) -> SQLTriplet:
376+
def sql_is_none(x: SQLExpression | Number | str | bool) -> SQLTriplet: # noqa: FBT001
377377
"""Check if x is None.
378378
379379
Returns:
@@ -384,7 +384,7 @@ def sql_is_none(x: SQLExpression | Number | str | bool) -> SQLTriplet:
384384
return SQLTriplet(x, "is_none")
385385

386386

387-
def sql_is_not_none(x: SQLExpression | Number | str | bool) -> SQLTriplet:
387+
def sql_is_not_none(x: SQLExpression | Number | str | bool) -> SQLTriplet: # noqa: FBT001
388388
"""Check if x is not None.
389389
390390
Returns:

0 commit comments

Comments
 (0)