Skip to content

Commit 840b2d6

Browse files
[ruff] Upgrade ruff to 0.15.7
updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.14 → v0.15.7](astral-sh/ruff-pre-commit@v0.14.14...v0.15.7)
1 parent ade2314 commit 840b2d6

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
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"]

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ lint.ignore = [
155155
"PLR2004", # Magic value used in comparison
156156
"PLR2044", # Line with empty comment
157157
"PLR5501", # Use `elif` instead of `else` then `if`
158+
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
158159
"PLW0120", # remove the else and dedent its contents
159160
"PLW0603", # Using the global statement
160161
"PLW1641", # Does not implement the __hash__ method
161162
"PLW2901", # for loop variable overwritten by assignment target
162163
# ruff ignore
163164
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
165+
"RUF061", # Use context-manager form of `pytest.raises()`
164166
]
165167
lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
166168
"B",
@@ -169,6 +171,8 @@ lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
169171
lint.per-file-ignores."src/_pytest/_version.py" = [
170172
"I001",
171173
]
174+
# 'Unnecessary membership test on empty collection', always voluntary in tests
175+
lint.per-file-ignores."testing/**/*.py" = [ "RUF060" ]
172176
# can't be disabled on a line-by-line basis in file
173177
lint.per-file-ignores."testing/code/test_source.py" = [
174178
"F841",

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 nodeid.split("::", maxsplit=1)[
1038+
0
1039+
] != nodes.norm_sep(fspath):
10381040
res += " <- " + bestrelpath(self.startpath, Path(fspath))
10391041
else:
10401042
res = "[location]"

0 commit comments

Comments
 (0)