Skip to content

Commit 62c0819

Browse files
Merge pull request #13082 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents 2931fdb + 8826bb8 commit 62c0819

20 files changed

+124
-114
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.8.3"
3+
rev: "v0.9.0"
44
hooks:
55
- id: ruff
66
args: ["--fix"]
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: check-yaml
1414
- repo: https://github.com/woodruffw/zizmor-pre-commit
15-
rev: v0.9.2
15+
rev: v1.0.1
1616
hooks:
1717
- id: zizmor
1818
- repo: https://github.com/adamchainz/blacken-docs
@@ -32,7 +32,7 @@ repos:
3232
hooks:
3333
- id: python-use-type-annotations
3434
- repo: https://github.com/pre-commit/mirrors-mypy
35-
rev: v1.13.0
35+
rev: v1.14.1
3636
hooks:
3737
- id: mypy
3838
files: ^(src/|testing/|scripts/)
@@ -54,7 +54,7 @@ repos:
5454
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version
5555
additional_dependencies: ["tox>=4.9"]
5656
- repo: https://github.com/asottile/pyupgrade
57-
rev: v3.19.0
57+
rev: v3.19.1
5858
hooks:
5959
- id: pyupgrade
6060
args:

doc/en/example/assertion/failure_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ class A:
267267
a = 1
268268

269269
b = 2
270-
assert (
271-
A.a == b
272-
), "A.a appears not to be b\nor does not appear to be b\none of those"
270+
assert A.a == b, (
271+
"A.a appears not to be b\nor does not appear to be b\none of those"
272+
)
273273

274274
def test_custom_repr(self):
275275
class JSON:

scripts/prepare-release-pr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def find_next_version(
163163
last_version = valid_versions[-1]
164164

165165
if is_major:
166-
return f"{last_version[0]+1}.0.0{prerelease}"
166+
return f"{last_version[0] + 1}.0.0{prerelease}"
167167
elif is_feature_release:
168168
return f"{last_version[0]}.{last_version[1] + 1}.0{prerelease}"
169169
else:

scripts/update-plugin-list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def version_sort_key(version_string: str) -> Any:
176176
)
177177
last_release = release_date.strftime("%b %d, %Y")
178178
break
179-
name = f':pypi:`{info["name"]}`'
179+
name = f":pypi:`{info['name']}`"
180180
summary = ""
181181
if info["summary"]:
182182
summary = escape_rst(info["summary"].replace("\n", ""))
@@ -194,7 +194,7 @@ def plugin_definitions(plugins: Iterable[PluginInfo]) -> Iterator[str]:
194194
for plugin in plugins:
195195
yield dedent(
196196
f"""
197-
{plugin['name']}
197+
{plugin["name"]}
198198
*last release*: {plugin["last_release"]},
199199
*status*: {plugin["status"]},
200200
*requires*: {plugin["requires"]}

src/_pytest/_code/code.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def relline(self) -> int:
217217
return self.lineno - self.frame.code.firstlineno
218218

219219
def __repr__(self) -> str:
220-
return f"<TracebackEntry {self.frame.code.path}:{self.lineno+1}>"
220+
return f"<TracebackEntry {self.frame.code.path}:{self.lineno + 1}>"
221221

222222
@property
223223
def statement(self) -> Source:
@@ -303,7 +303,7 @@ def __str__(self) -> str:
303303
# This output does not quite match Python's repr for traceback entries,
304304
# but changing it to do so would break certain plugins. See
305305
# https://github.com/pytest-dev/pytest/pull/7535/ for details.
306-
return f" File '{self.path}':{self.lineno+1} in {name}\n {line}\n"
306+
return f" File '{self.path}':{self.lineno + 1} in {name}\n {line}\n"
307307

308308
@property
309309
def name(self) -> str:
@@ -527,33 +527,33 @@ def fill_unfilled(self, exc_info: tuple[type[E], E, TracebackType]) -> None:
527527
@property
528528
def type(self) -> type[E]:
529529
"""The exception class."""
530-
assert (
531-
self._excinfo is not None
532-
), ".type can only be used after the context manager exits"
530+
assert self._excinfo is not None, (
531+
".type can only be used after the context manager exits"
532+
)
533533
return self._excinfo[0]
534534

535535
@property
536536
def value(self) -> E:
537537
"""The exception value."""
538-
assert (
539-
self._excinfo is not None
540-
), ".value can only be used after the context manager exits"
538+
assert self._excinfo is not None, (
539+
".value can only be used after the context manager exits"
540+
)
541541
return self._excinfo[1]
542542

543543
@property
544544
def tb(self) -> TracebackType:
545545
"""The exception raw traceback."""
546-
assert (
547-
self._excinfo is not None
548-
), ".tb can only be used after the context manager exits"
546+
assert self._excinfo is not None, (
547+
".tb can only be used after the context manager exits"
548+
)
549549
return self._excinfo[2]
550550

551551
@property
552552
def typename(self) -> str:
553553
"""The type name of the exception."""
554-
assert (
555-
self._excinfo is not None
556-
), ".typename can only be used after the context manager exits"
554+
assert self._excinfo is not None, (
555+
".typename can only be used after the context manager exits"
556+
)
557557
return self.type.__name__
558558

559559
@property

src/_pytest/_py/error.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,21 @@ def checked_call(
9090
except OSError as value:
9191
if not hasattr(value, "errno"):
9292
raise
93-
errno = value.errno
9493
if sys.platform == "win32":
9594
try:
96-
cls = self._geterrnoclass(_winerrnomap[errno])
95+
cls = self._geterrnoclass(_winerrnomap[value.errno])
9796
except KeyError:
9897
raise value
9998
else:
10099
# we are not on Windows, or we got a proper OSError
101-
cls = self._geterrnoclass(errno)
100+
if value.errno is None:
101+
cls = type(
102+
"UnknownErrnoNone",
103+
(Error,),
104+
{"__module__": "py.error", "__doc__": None},
105+
)
106+
else:
107+
cls = self._geterrnoclass(value.errno)
102108

103109
raise cls(f"{func.__name__}{args!r}")
104110

src/_pytest/cacheprovider.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@ def pytest_addoption(parser: Parser) -> None:
482482
"--last-failed",
483483
action="store_true",
484484
dest="lf",
485-
help="Rerun only the tests that failed "
486-
"at the last run (or all if none failed)",
485+
help="Rerun only the tests that failed at the last run (or all if none failed)",
487486
)
488487
group.addoption(
489488
"--ff",

src/_pytest/capture.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ def __repr__(self) -> str:
375375
)
376376

377377
def _assert_state(self, op: str, states: tuple[str, ...]) -> None:
378-
assert (
379-
self._state in states
380-
), "cannot {} in state {!r}: expected one of {}".format(
381-
op, self._state, ", ".join(states)
378+
assert self._state in states, (
379+
"cannot {} in state {!r}: expected one of {}".format(
380+
op, self._state, ", ".join(states)
381+
)
382382
)
383383

384384
def start(self) -> None:
@@ -492,10 +492,10 @@ def __repr__(self) -> str:
492492
)
493493

494494
def _assert_state(self, op: str, states: tuple[str, ...]) -> None:
495-
assert (
496-
self._state in states
497-
), "cannot {} in state {!r}: expected one of {}".format(
498-
op, self._state, ", ".join(states)
495+
assert self._state in states, (
496+
"cannot {} in state {!r}: expected one of {}".format(
497+
op, self._state, ", ".join(states)
498+
)
499499
)
500500

501501
def start(self) -> None:

src/_pytest/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def getlocation(function, curdir: str | os.PathLike[str] | None = None) -> str:
7070
except ValueError:
7171
pass
7272
else:
73-
return f"{relfn}:{lineno+1}"
74-
return f"{fn}:{lineno+1}"
73+
return f"{relfn}:{lineno + 1}"
74+
return f"{fn}:{lineno + 1}"
7575

7676

7777
def num_mock_patch_args(function) -> int:

src/_pytest/config/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ def import_plugin(self, modname: str, consider_entry_points: bool = False) -> No
838838
# "terminal" or "capture". Those plugins are registered under their
839839
# basename for historic purposes but must be imported with the
840840
# _pytest prefix.
841-
assert isinstance(
842-
modname, str
843-
), f"module name as text required, got {modname!r}"
841+
assert isinstance(modname, str), (
842+
f"module name as text required, got {modname!r}"
843+
)
844844
if self.is_blocked(modname) or self.get_plugin(modname) is not None:
845845
return
846846

@@ -1503,9 +1503,9 @@ def _get_unknown_ini_keys(self) -> list[str]:
15031503

15041504
def parse(self, args: list[str], addopts: bool = True) -> None:
15051505
# Parse given cmdline arguments into this config object.
1506-
assert (
1507-
self.args == []
1508-
), "can only parse cmdline args at most once per Config object"
1506+
assert self.args == [], (
1507+
"can only parse cmdline args at most once per Config object"
1508+
)
15091509
self.hook.pytest_addhooks.call_historic(
15101510
kwargs=dict(pluginmanager=self.pluginmanager)
15111511
)

0 commit comments

Comments
 (0)