Skip to content

Commit 9bc25f7

Browse files
committed
chore: Update Ruff linters
1 parent 7f39996 commit 9bc25f7

7 files changed

+59
-19
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
1010
rev: v0.12.2
1111
hooks:
12-
- id: ruff
12+
- id: ruff-check
1313
- id: ruff-format
1414

1515
- repo: https://github.com/gitleaks/gitleaks

example/ex_6_creating_retryable_stages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# SPDX-License-Identifier: BSD-3-Clause
99

10+
from __future__ import annotations
11+
1012
import argparse
1113
import functools
1214
import sys

example/ex_7_customizing_the_summary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# SPDX-License-Identifier: BSD-3-Clause
99

10+
from __future__ import annotations
11+
1012
import argparse
1113
import functools
1214
import platform

pyproject.toml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,40 +73,74 @@ line-length = 79
7373
[tool.ruff.lint]
7474
extend-select = [
7575
"A",
76+
"AIR",
77+
# "ANN",
78+
"ARG",
79+
"ASYNC",
7680
"B",
7781
"BLE",
7882
"C4",
7983
"C90",
8084
"D",
85+
"DJ",
8186
"DTZ",
8287
"E",
8388
"EM",
8489
"ERA",
8590
"EXE",
91+
"F",
92+
"FA",
8693
"FBT",
94+
"FIX",
95+
"FLY",
96+
"FURB",
97+
"G",
98+
"ICN",
99+
"INP",
100+
"INT",
101+
"ISC",
102+
"LOG",
103+
"N",
87104
"NPY",
105+
"PD",
106+
"PERF",
88107
"PGH",
108+
"PIE",
89109
"PL",
90110
"PT",
91111
"PTH",
112+
"PYI",
113+
"Q",
92114
"RET",
93115
"RSE",
94116
"RUF",
95117
"S",
96118
"SIM",
119+
# "SLF",
120+
"SLOT",
121+
"T10",
122+
"T20",
123+
"TC",
124+
"TD",
97125
"TID",
98126
"TCH",
99127
"TRY",
100128
"UP",
101129
"W",
130+
"YTT",
102131
]
103132
ignore = [
104133
"D212",
105134
]
106135

107136

108137
[tool.ruff.lint.per-file-ignores]
109-
"**/test_*.py" = ["S101"]
138+
"**/test_*.py" = [
139+
"S101",
140+
"SLF001",
141+
"T201",
142+
]
143+
"doc/source/conf.py" = ["INP001"]
110144
"example/*.py" = [
111145
"D101",
112146
"D102",
@@ -121,6 +155,10 @@ ignore = [
121155
convention = "google"
122156

123157

158+
[tool.ruff.lint.pyupgrade]
159+
keep-runtime-typing = true
160+
161+
124162
[tool.semantic_release]
125163
build_command = "python3 -m pip install poetry && poetry build"
126164
commit_message = """

staged_script/staged_script.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
# SPDX-License-Identifier: BSD-3-Clause
1313

14+
from __future__ import annotations
15+
1416
import functools
1517
import re
1618
import shlex
@@ -365,7 +367,6 @@ def _run_pre_stage_actions(self) -> None:
365367
were met before attempting the stage, and erroring out
366368
appropriately if not.
367369
"""
368-
pass
369370

370371
def _begin_stage(self, heading: str) -> None:
371372
"""
@@ -495,7 +496,6 @@ def _run_post_stage_actions(self) -> None:
495496
were met before moving on, and erroring out appropriately if
496497
not.
497498
"""
498-
pass
499499

500500
def _prepare_to_retry_stage(self, retry_state: RetryCallState) -> None:
501501
"""
@@ -1023,8 +1023,6 @@ class RetryStage(TryAgain):
10231023
that a stage should be retried.
10241024
"""
10251025

1026-
pass
1027-
10281026

10291027
class HelpFormatter(
10301028
ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter
@@ -1036,5 +1034,3 @@ class HelpFormatter(
10361034
treats the description as raw text (doesn't do any automatic
10371035
formatting) and shows default values of arguments.
10381036
"""
1039-
1040-
pass

test/test_staged_script.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# SPDX-License-Identifier: BSD-3-Clause
88

9+
from __future__ import annotations
10+
911
import shlex
1012
from datetime import datetime, timedelta, timezone
1113
from subprocess import CompletedProcess
@@ -91,15 +93,15 @@ def test__skip_stage(
9193
@pytest.mark.parametrize("retry_attempts", [0, 5])
9294
@patch("tenacity.Retrying")
9395
def test__handle_stage_retry_error(
94-
mock_Retrying: MagicMock,
96+
mock_retrying: MagicMock,
9597
retry_attempts: int,
9698
script: StagedScript,
9799
capsys: pytest.CaptureFixture,
98100
) -> None:
99101
"""Test the :func:`_handle_stage_retry_error` method."""
100102
script.current_stage = "test"
101103
script.test_retry_attempts = retry_attempts # type: ignore[attr-defined]
102-
retry = mock_Retrying()
104+
retry = mock_retrying()
103105
retry.statistics = {
104106
"delay_since_first_attempt": 1234,
105107
"attempt_number": retry_attempts,
@@ -121,14 +123,14 @@ def test__handle_stage_retry_error(
121123

122124
@patch("tenacity.RetryCallState")
123125
def test__prepare_to_retry_stage(
124-
mock_RetryCallState: MagicMock,
126+
mock_retry_call_state: MagicMock,
125127
script: StagedScript,
126128
capsys: pytest.CaptureFixture,
127129
) -> None:
128130
"""Test the :func:`_prepare_to_retry_stage` method."""
129131
script.current_stage = "test"
130-
retry_state = mock_RetryCallState()
131-
retry_state.__repr__ = lambda self: "mock_RetryCallState.__repr__"
132+
retry_state = mock_retry_call_state()
133+
retry_state.__repr__ = lambda _self: "mock_RetryCallState.__repr__"
132134
script._prepare_to_retry_stage(retry_state)
133135
captured = capsys.readouterr()
134136
for text in [

test/test_staged_script_advanced_subclass.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run_test(self, *, retry: bool = False) -> None:
4242
def _run_pre_stage_actions(self) -> None:
4343
print("inside '_run_pre_stage_actions' function")
4444

45-
def _begin_stage(self, heading: str) -> None:
45+
def _begin_stage(self, _heading: str) -> None:
4646
print("inside '_begin_stage' function")
4747

4848
def _skip_stage(self) -> None:
@@ -54,10 +54,10 @@ def _end_stage(self) -> None:
5454
def _run_post_stage_actions(self) -> None:
5555
print("inside '_run_post_stage_actions' function")
5656

57-
def _handle_stage_retry_error(self, retry: Retrying) -> None:
57+
def _handle_stage_retry_error(self, _retry: Retrying) -> None:
5858
print("inside '_handle_stage_retry_error' function")
5959

60-
def _prepare_to_retry_stage(self, retry_state: RetryCallState) -> None:
60+
def _prepare_to_retry_stage(self, _retry_state: RetryCallState) -> None:
6161
print("inside '_prepare_to_retry_stage' function")
6262

6363

@@ -125,7 +125,7 @@ def test_stage( # noqa: PLR0913
125125
)
126126
if custom_begin_stage:
127127
script._begin_stage_test = ( # type: ignore[attr-defined]
128-
lambda heading: print("inside '_begin_stage_test' function")
128+
lambda _heading: print("inside '_begin_stage_test' function")
129129
)
130130
if custom_skip_stage:
131131
script._skip_stage_test = lambda: print( # type: ignore[attr-defined]
@@ -178,13 +178,13 @@ def test_stage_retry(
178178
script.stages_to_run = {"test"}
179179
if custom_prepare_to_retry:
180180
script._prepare_to_retry_stage_test = ( # type: ignore[attr-defined]
181-
lambda retry_state: print(
181+
lambda _retry_state: print(
182182
"inside '_prepare_to_retry_stage_test' function"
183183
)
184184
)
185185
if custom_handle_retry_error:
186186
script._handle_stage_retry_error_test = ( # type: ignore[attr-defined]
187-
lambda retry: print(
187+
lambda _retry: print(
188188
"inside '_handle_stage_retry_error_test' function"
189189
)
190190
)

0 commit comments

Comments
 (0)