Skip to content

Commit 2ca0f8a

Browse files
Merge pull request #14175 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents abdb2b6 + 51eb7a4 commit 2ca0f8a

6 files changed

Lines changed: 26 additions & 20 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
minimum_pre_commit_version: "4.4.0"
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.14.14"
4+
rev: "v0.15.7"
55
hooks:
66
- id: ruff-check
77
args: ["--fix"]
@@ -13,7 +13,7 @@ repos:
1313
- id: end-of-file-fixer
1414
- id: check-yaml
1515
- repo: https://github.com/woodruffw/zizmor-pre-commit
16-
rev: v1.22.0
16+
rev: v1.23.1
1717
hooks:
1818
- id: zizmor
1919
args: ["--fix", "--no-progress"]
@@ -23,7 +23,7 @@ repos:
2323
- id: blacken-docs
2424
additional_dependencies: [black==24.1.1]
2525
- repo: https://github.com/codespell-project/codespell
26-
rev: v2.4.1
26+
rev: v2.4.2
2727
hooks:
2828
- id: codespell
2929
args: ["--toml=pyproject.toml"]
@@ -67,7 +67,7 @@ repos:
6767
- exceptiongroup>=1.0.0rc8
6868
# Manual because passing pyright is a work in progress.
6969
stages: [manual]
70-
- repo: https://github.com/tox-dev/pyproject-fmt
70+
- repo: https://github.com/pytest-dev/pyproject-fmt
7171
rev: "v2.12.1"
7272
hooks:
7373
- id: pyproject-fmt

pyproject.toml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ lint.ignore = [
161161
"PLW2901", # for loop variable overwritten by assignment target
162162
# ruff ignore
163163
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
164+
"RUF061", # Use context-manager form of `pytest.raises()`
164165
]
165166
lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
166167
"B",
@@ -169,6 +170,8 @@ lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
169170
lint.per-file-ignores."src/_pytest/_version.py" = [
170171
"I001",
171172
]
173+
# 'Unnecessary membership test on empty collection', always voluntary in tests
174+
lint.per-file-ignores."testing/**/*.py" = [ "RUF060" ]
172175
# can't be disabled on a line-by-line basis in file
173176
lint.per-file-ignores."testing/code/test_source.py" = [
174177
"F841",
@@ -217,31 +220,30 @@ disable = [
217220
"comparison-with-callable",
218221
"comparison-with-itself", # PLR0124 from ruff
219222
"condition-evals-to-constant",
220-
"consider-alternative-union-syntax",
221223
"confusing-consecutive-elif",
224+
"consider-alternative-union-syntax",
225+
"consider-ternary-expression",
222226
"consider-using-assignment-expr",
223227
"consider-using-dict-items",
224-
"consider-using-from-import",
228+
"consider-using-from-import", # not activated by default, PLR0402 disabled in ruff
225229
"consider-using-f-string",
226230
"consider-using-in",
227231
"consider-using-namedtuple-or-dataclass",
228232
"consider-using-ternary",
229233
"consider-using-tuple",
230234
"consider-using-with",
231-
"consider-using-from-import", # not activated by default, PLR0402 disabled in ruff
232-
"consider-ternary-expression",
233235
"cyclic-import",
234-
"differing-param-doc",
235-
"docstring-first-line-empty",
236236
"deprecated-argument",
237237
"deprecated-attribute",
238238
"deprecated-class",
239+
"differing-param-doc",
239240
"disallowed-name", # foo / bar are used often in tests
241+
"docstring-first-line-empty",
240242
"duplicate-code",
241243
"else-if-used", # not activated by default, PLR5501 disabled in ruff
242244
"empty-comment", # not activated by default, PLR2044 disabled in ruff
243-
"eval-used",
244245
"eq-without-hash", # PLW1641 disabled in ruff
246+
"eval-used",
245247
"exec-used",
246248
"expression-not-assigned",
247249
"fixme",
@@ -258,13 +260,13 @@ disable = [
258260
"line-too-long",
259261
"magic-value-comparison", # not activated by default, PLR2004 disabled in ruff
260262
"method-hidden",
263+
"misplaced-bare-raise", # PLE0704 from ruff
264+
"misplaced-comparison-constant",
261265
"missing-docstring",
262266
"missing-param-doc",
263267
"missing-raises-doc",
264268
"missing-timeout",
265269
"missing-type-doc",
266-
"misplaced-bare-raise", # PLE0704 from ruff
267-
"misplaced-comparison-constant",
268270
"multiple-statements", # multiple-statements-on-one-line-colon (E701) from ruff
269271
"no-else-break",
270272
"no-else-continue",
@@ -329,10 +331,10 @@ disable = [
329331
"use-dict-literal",
330332
"use-implicit-booleaness-not-comparison",
331333
"use-implicit-booleaness-not-len",
332-
"use-set-for-membership",
333334
"useless-else-on-loop", # PLC0414 disabled in ruff
334335
"useless-import-alias",
335336
"useless-return",
337+
"use-set-for-membership",
336338
"using-constant-test",
337339
"while-used",
338340
"wrong-import-order", # handled by isort / ruff

src/_pytest/config/findpaths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def is_option(x: str) -> bool:
233233
return x.startswith("-")
234234

235235
def get_file_part_from_node_id(x: str) -> str:
236-
return x.split("::")[0]
236+
return x.split("::", maxsplit=1)[0]
237237

238238
def get_dir_from_path(path: Path) -> Path:
239239
if path.is_dir():

src/_pytest/terminal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def hasopt(self, char: str) -> bool:
476476
return char in self.reportchars
477477

478478
def write_fspath_result(self, nodeid: str, res: str, **markup: bool) -> None:
479-
fspath = self.config.rootpath / nodeid.split("::")[0]
479+
fspath = self.config.rootpath / nodeid.split("::", maxsplit=1)[0]
480480
if self.currentfspath is None or fspath != self.currentfspath:
481481
if self.currentfspath is not None and self._show_progress_info:
482482
self._write_progress_information_filling_space()
@@ -1034,7 +1034,9 @@ def mkrel(nodeid: str) -> str:
10341034
# fspath comes from testid which has a "/"-normalized path.
10351035
if fspath:
10361036
res = mkrel(nodeid)
1037-
if self.verbosity >= 2 and nodeid.split("::")[0] != nodes.norm_sep(fspath):
1037+
if self.verbosity >= 2 and (
1038+
nodeid.split("::", maxsplit=1)[0] != nodes.norm_sep(fspath)
1039+
):
10381040
res += " <- " + bestrelpath(self.startpath, Path(fspath))
10391041
else:
10401042
res = "[location]"

src/_pytest/timing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ class Instant:
3232

3333
# Creation time of this instant, using time.time(), to measure actual time.
3434
# Note: using a `lambda` to correctly get the mocked time via `MockTiming`.
35-
time: float = dataclasses.field(default_factory=lambda: time(), init=False)
35+
# pylint: disable-next=lambda-assignment
36+
time: float = dataclasses.field(default_factory=lambda: time(), init=False) # noqa: PLW0108
3637

3738
# Performance counter tick of the instant, used to measure precise elapsed time.
3839
# Note: using a `lambda` to correctly get the mocked time via `MockTiming`.
3940
perf_count: float = dataclasses.field(
40-
default_factory=lambda: perf_counter(), init=False
41+
default_factory=lambda: perf_counter(), # noqa: PLW0108
42+
init=False,
4143
)
4244

4345
def elapsed(self) -> Duration:

testing/_py/test_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ def test_stat_helpers(self, tmpdir, monkeypatch):
13881388

13891389
def test_stat_non_raising(self, tmpdir):
13901390
path1 = tmpdir.join("file")
1391-
pytest.raises(error.ENOENT, lambda: path1.stat())
1391+
pytest.raises(error.ENOENT, path1.stat)
13921392
res = path1.stat(raising=False)
13931393
assert res is None
13941394

0 commit comments

Comments
 (0)