Skip to content

Commit d2bb828

Browse files
pre-commit-ci[bot]Pierre-Sassoulas
authored andcommitted
[pre-commit.ci] pre-commit autoupdate (#12712)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.6 → v0.5.7](astral-sh/ruff-pre-commit@v0.5.6...v0.5.7) * Apply pyupgrade latest changes Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 0765c55 commit d2bb828

24 files changed

+60
-68
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
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.5.6"
3+
rev: "v0.5.7"
44
hooks:
55
- id: ruff
66
args: ["--fix"]

src/_pytest/cacheprovider.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def pytest_collectreport(self, report: CollectReport) -> None:
369369
@hookimpl(wrapper=True, tryfirst=True)
370370
def pytest_collection_modifyitems(
371371
self, config: Config, items: list[nodes.Item]
372-
) -> Generator[None, None, None]:
372+
) -> Generator[None]:
373373
res = yield
374374

375375
if not self.active:
@@ -439,9 +439,7 @@ def __init__(self, config: Config) -> None:
439439
self.cached_nodeids = set(config.cache.get("cache/nodeids", []))
440440

441441
@hookimpl(wrapper=True, tryfirst=True)
442-
def pytest_collection_modifyitems(
443-
self, items: list[nodes.Item]
444-
) -> Generator[None, None, None]:
442+
def pytest_collection_modifyitems(self, items: list[nodes.Item]) -> Generator[None]:
445443
res = yield
446444

447445
if self.active:

src/_pytest/capture.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _reopen_stdio(f, mode):
135135

136136

137137
@hookimpl(wrapper=True)
138-
def pytest_load_initial_conftests(early_config: Config) -> Generator[None, None, None]:
138+
def pytest_load_initial_conftests(early_config: Config) -> Generator[None]:
139139
ns = early_config.known_args_namespace
140140
if ns.capture == "fd":
141141
_windowsconsoleio_workaround(sys.stdout)
@@ -817,7 +817,7 @@ def resume_fixture(self) -> None:
817817
# Helper context managers
818818

819819
@contextlib.contextmanager
820-
def global_and_fixture_disabled(self) -> Generator[None, None, None]:
820+
def global_and_fixture_disabled(self) -> Generator[None]:
821821
"""Context manager to temporarily disable global and current fixture capturing."""
822822
do_fixture = self._capture_fixture and self._capture_fixture._is_started()
823823
if do_fixture:
@@ -834,7 +834,7 @@ def global_and_fixture_disabled(self) -> Generator[None, None, None]:
834834
self.resume_fixture()
835835

836836
@contextlib.contextmanager
837-
def item_capture(self, when: str, item: Item) -> Generator[None, None, None]:
837+
def item_capture(self, when: str, item: Item) -> Generator[None]:
838838
self.resume_global_capture()
839839
self.activate_fixture()
840840
try:
@@ -869,17 +869,17 @@ def pytest_make_collect_report(
869869
return rep
870870

871871
@hookimpl(wrapper=True)
872-
def pytest_runtest_setup(self, item: Item) -> Generator[None, None, None]:
872+
def pytest_runtest_setup(self, item: Item) -> Generator[None]:
873873
with self.item_capture("setup", item):
874874
return (yield)
875875

876876
@hookimpl(wrapper=True)
877-
def pytest_runtest_call(self, item: Item) -> Generator[None, None, None]:
877+
def pytest_runtest_call(self, item: Item) -> Generator[None]:
878878
with self.item_capture("call", item):
879879
return (yield)
880880

881881
@hookimpl(wrapper=True)
882-
def pytest_runtest_teardown(self, item: Item) -> Generator[None, None, None]:
882+
def pytest_runtest_teardown(self, item: Item) -> Generator[None]:
883883
with self.item_capture("teardown", item):
884884
return (yield)
885885

@@ -961,7 +961,7 @@ def _is_started(self) -> bool:
961961
return False
962962

963963
@contextlib.contextmanager
964-
def disabled(self) -> Generator[None, None, None]:
964+
def disabled(self) -> Generator[None]:
965965
"""Temporarily disable capturing while inside the ``with`` block."""
966966
capmanager: CaptureManager = self.request.config.pluginmanager.getplugin(
967967
"capturemanager"
@@ -974,7 +974,7 @@ def disabled(self) -> Generator[None, None, None]:
974974

975975

976976
@fixture
977-
def capsys(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
977+
def capsys(request: SubRequest) -> Generator[CaptureFixture[str]]:
978978
r"""Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
979979
980980
The captured output is made available via ``capsys.readouterr()`` method
@@ -1002,7 +1002,7 @@ def test_output(capsys):
10021002

10031003

10041004
@fixture
1005-
def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
1005+
def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]:
10061006
r"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
10071007
10081008
The captured output is made available via ``capsysbinary.readouterr()``
@@ -1030,7 +1030,7 @@ def test_output(capsysbinary):
10301030

10311031

10321032
@fixture
1033-
def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
1033+
def capfd(request: SubRequest) -> Generator[CaptureFixture[str]]:
10341034
r"""Enable text capturing of writes to file descriptors ``1`` and ``2``.
10351035
10361036
The captured output is made available via ``capfd.readouterr()`` method
@@ -1058,7 +1058,7 @@ def test_system_echo(capfd):
10581058

10591059

10601060
@fixture
1061-
def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
1061+
def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]:
10621062
r"""Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
10631063
10641064
The captured output is made available via ``capfd.readouterr()`` method

src/_pytest/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def _is_mocked(obj: object) -> bool:
468468

469469

470470
@contextmanager
471-
def _patch_unwrap_mock_aware() -> Generator[None, None, None]:
471+
def _patch_unwrap_mock_aware() -> Generator[None]:
472472
"""Context manager which replaces ``inspect.unwrap`` with a version
473473
that's aware of mock objects and doesn't recurse into them."""
474474
real_unwrap = inspect.unwrap

src/_pytest/logging.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,7 @@ def set_level(self, level: int | str, logger: str | None = None) -> None:
554554
self._initial_disabled_logging_level = initial_disabled_logging_level
555555

556556
@contextmanager
557-
def at_level(
558-
self, level: int | str, logger: str | None = None
559-
) -> Generator[None, None, None]:
557+
def at_level(self, level: int | str, logger: str | None = None) -> Generator[None]:
560558
"""Context manager that sets the level for capturing of logs. After
561559
the end of the 'with' statement the level is restored to its original
562560
value.
@@ -580,7 +578,7 @@ def at_level(
580578
logging.disable(original_disable_level)
581579

582580
@contextmanager
583-
def filtering(self, filter_: logging.Filter) -> Generator[None, None, None]:
581+
def filtering(self, filter_: logging.Filter) -> Generator[None]:
584582
"""Context manager that temporarily adds the given filter to the caplog's
585583
:meth:`handler` for the 'with' statement block, and removes that filter at the
586584
end of the block.
@@ -597,7 +595,7 @@ def filtering(self, filter_: logging.Filter) -> Generator[None, None, None]:
597595

598596

599597
@fixture
600-
def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture, None, None]:
598+
def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture]:
601599
"""Access and control log capturing.
602600
603601
Captured logs are available through the following properties/methods::
@@ -776,15 +774,15 @@ def _log_cli_enabled(self) -> bool:
776774
return True
777775

778776
@hookimpl(wrapper=True, tryfirst=True)
779-
def pytest_sessionstart(self) -> Generator[None, None, None]:
777+
def pytest_sessionstart(self) -> Generator[None]:
780778
self.log_cli_handler.set_when("sessionstart")
781779

782780
with catching_logs(self.log_cli_handler, level=self.log_cli_level):
783781
with catching_logs(self.log_file_handler, level=self.log_file_level):
784782
return (yield)
785783

786784
@hookimpl(wrapper=True, tryfirst=True)
787-
def pytest_collection(self) -> Generator[None, None, None]:
785+
def pytest_collection(self) -> Generator[None]:
788786
self.log_cli_handler.set_when("collection")
789787

790788
with catching_logs(self.log_cli_handler, level=self.log_cli_level):
@@ -813,7 +811,7 @@ def pytest_runtest_logstart(self) -> None:
813811
def pytest_runtest_logreport(self) -> None:
814812
self.log_cli_handler.set_when("logreport")
815813

816-
def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, None]:
814+
def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None]:
817815
"""Implement the internals of the pytest_runtest_xxx() hooks."""
818816
with catching_logs(
819817
self.caplog_handler,
@@ -834,21 +832,21 @@ def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, Non
834832
item.add_report_section(when, "log", log)
835833

836834
@hookimpl(wrapper=True)
837-
def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None, None, None]:
835+
def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None]:
838836
self.log_cli_handler.set_when("setup")
839837

840838
empty: dict[str, list[logging.LogRecord]] = {}
841839
item.stash[caplog_records_key] = empty
842840
yield from self._runtest_for(item, "setup")
843841

844842
@hookimpl(wrapper=True)
845-
def pytest_runtest_call(self, item: nodes.Item) -> Generator[None, None, None]:
843+
def pytest_runtest_call(self, item: nodes.Item) -> Generator[None]:
846844
self.log_cli_handler.set_when("call")
847845

848846
yield from self._runtest_for(item, "call")
849847

850848
@hookimpl(wrapper=True)
851-
def pytest_runtest_teardown(self, item: nodes.Item) -> Generator[None, None, None]:
849+
def pytest_runtest_teardown(self, item: nodes.Item) -> Generator[None]:
852850
self.log_cli_handler.set_when("teardown")
853851

854852
try:
@@ -862,7 +860,7 @@ def pytest_runtest_logfinish(self) -> None:
862860
self.log_cli_handler.set_when("finish")
863861

864862
@hookimpl(wrapper=True, tryfirst=True)
865-
def pytest_sessionfinish(self) -> Generator[None, None, None]:
863+
def pytest_sessionfinish(self) -> Generator[None]:
866864
self.log_cli_handler.set_when("sessionfinish")
867865

868866
with catching_logs(self.log_cli_handler, level=self.log_cli_level):

src/_pytest/monkeypatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
@fixture
31-
def monkeypatch() -> Generator[MonkeyPatch, None, None]:
31+
def monkeypatch() -> Generator[MonkeyPatch]:
3232
"""A convenient fixture for monkey-patching.
3333
3434
The fixture provides these methods to modify objects, dictionaries, or
@@ -135,7 +135,7 @@ def __init__(self) -> None:
135135

136136
@classmethod
137137
@contextmanager
138-
def context(cls) -> Generator[MonkeyPatch, None, None]:
138+
def context(cls) -> Generator[MonkeyPatch]:
139139
"""Context manager that returns a new :class:`MonkeyPatch` object
140140
which undoes any patching done inside the ``with`` block upon exit.
141141

src/_pytest/pytester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def pytester(
491491

492492

493493
@fixture
494-
def _sys_snapshot() -> Generator[None, None, None]:
494+
def _sys_snapshot() -> Generator[None]:
495495
snappaths = SysPathsSnapshot()
496496
snapmods = SysModulesSnapshot()
497497
yield
@@ -500,7 +500,7 @@ def _sys_snapshot() -> Generator[None, None, None]:
500500

501501

502502
@fixture
503-
def _config_for_test() -> Generator[Config, None, None]:
503+
def _config_for_test() -> Generator[Config]:
504504
from _pytest.config import get_config
505505

506506
config = get_config()

src/_pytest/python.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def _register_setup_module_fixture(self) -> None:
568568
if setup_module is None and teardown_module is None:
569569
return
570570

571-
def xunit_setup_module_fixture(request) -> Generator[None, None, None]:
571+
def xunit_setup_module_fixture(request) -> Generator[None]:
572572
module = request.module
573573
if setup_module is not None:
574574
_call_with_optional_argument(setup_module, module)
@@ -599,7 +599,7 @@ def _register_setup_function_fixture(self) -> None:
599599
if setup_function is None and teardown_function is None:
600600
return
601601

602-
def xunit_setup_function_fixture(request) -> Generator[None, None, None]:
602+
def xunit_setup_function_fixture(request) -> Generator[None]:
603603
if request.instance is not None:
604604
# in this case we are bound to an instance, so we need to let
605605
# setup_method handle this
@@ -780,7 +780,7 @@ def _register_setup_class_fixture(self) -> None:
780780
if setup_class is None and teardown_class is None:
781781
return
782782

783-
def xunit_setup_class_fixture(request) -> Generator[None, None, None]:
783+
def xunit_setup_class_fixture(request) -> Generator[None]:
784784
cls = request.cls
785785
if setup_class is not None:
786786
func = getimfunc(setup_class)
@@ -813,7 +813,7 @@ def _register_setup_method_fixture(self) -> None:
813813
if setup_method is None and teardown_method is None:
814814
return
815815

816-
def xunit_setup_method_fixture(request) -> Generator[None, None, None]:
816+
def xunit_setup_method_fixture(request) -> Generator[None]:
817817
instance = request.instance
818818
method = request.function
819819
if setup_method is not None:

src/_pytest/recwarn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
@fixture
35-
def recwarn() -> Generator[WarningsRecorder, None, None]:
35+
def recwarn() -> Generator[WarningsRecorder]:
3636
"""Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
3737
3838
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information

src/_pytest/skipping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def pytest_runtest_setup(item: Item) -> None:
245245

246246

247247
@hookimpl(wrapper=True)
248-
def pytest_runtest_call(item: Item) -> Generator[None, None, None]:
248+
def pytest_runtest_call(item: Item) -> Generator[None]:
249249
xfailed = item.stash.get(xfailed_key, None)
250250
if xfailed is None:
251251
item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)

src/_pytest/terminal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None:
889889
@hookimpl(wrapper=True)
890890
def pytest_sessionfinish(
891891
self, session: Session, exitstatus: int | ExitCode
892-
) -> Generator[None, None, None]:
892+
) -> Generator[None]:
893893
result = yield
894894
self._tw.line("")
895895
summary_exit_codes = (
@@ -914,7 +914,7 @@ def pytest_sessionfinish(
914914
return result
915915

916916
@hookimpl(wrapper=True)
917-
def pytest_terminal_summary(self) -> Generator[None, None, None]:
917+
def pytest_terminal_summary(self) -> Generator[None]:
918918
self.summary_errors()
919919
self.summary_failures()
920920
self.summary_xfailures()

src/_pytest/threadexception.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __exit__(
6262
del self.args
6363

6464

65-
def thread_exception_runtest_hook() -> Generator[None, None, None]:
65+
def thread_exception_runtest_hook() -> Generator[None]:
6666
with catch_threading_exception() as cm:
6767
try:
6868
yield
@@ -83,15 +83,15 @@ def thread_exception_runtest_hook() -> Generator[None, None, None]:
8383

8484

8585
@pytest.hookimpl(wrapper=True, trylast=True)
86-
def pytest_runtest_setup() -> Generator[None, None, None]:
86+
def pytest_runtest_setup() -> Generator[None]:
8787
yield from thread_exception_runtest_hook()
8888

8989

9090
@pytest.hookimpl(wrapper=True, tryfirst=True)
91-
def pytest_runtest_call() -> Generator[None, None, None]:
91+
def pytest_runtest_call() -> Generator[None]:
9292
yield from thread_exception_runtest_hook()
9393

9494

9595
@pytest.hookimpl(wrapper=True, tryfirst=True)
96-
def pytest_runtest_teardown() -> Generator[None, None, None]:
96+
def pytest_runtest_teardown() -> Generator[None]:
9797
yield from thread_exception_runtest_hook()

src/_pytest/tmpdir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path:
256256
@fixture
257257
def tmp_path(
258258
request: FixtureRequest, tmp_path_factory: TempPathFactory
259-
) -> Generator[Path, None, None]:
259+
) -> Generator[Path]:
260260
"""Return a temporary directory path object which is unique to each test
261261
function invocation, created as a sub directory of the base temporary
262262
directory.

src/_pytest/unittest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def process_teardown_exceptions() -> None:
137137

138138
def unittest_setup_class_fixture(
139139
request: FixtureRequest,
140-
) -> Generator[None, None, None]:
140+
) -> Generator[None]:
141141
cls = request.cls
142142
if _is_skipped(cls):
143143
reason = cls.__unittest_skip_why__
@@ -178,7 +178,7 @@ def _register_unittest_setup_method_fixture(self, cls: type) -> None:
178178

179179
def unittest_setup_method_fixture(
180180
request: FixtureRequest,
181-
) -> Generator[None, None, None]:
181+
) -> Generator[None]:
182182
self = request.instance
183183
if _is_skipped(self):
184184
reason = self.__unittest_skip_why__

0 commit comments

Comments
 (0)