Skip to content

[pre-commit.ci] pre-commit autoupdate #12712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.6"
rev: "v0.5.7"
hooks:
- id: ruff
args: ["--fix"]
Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def pytest_collectreport(self, report: CollectReport) -> None:
@hookimpl(wrapper=True, tryfirst=True)
def pytest_collection_modifyitems(
self, config: Config, items: list[nodes.Item]
) -> Generator[None, None, None]:
) -> Generator[None]:
res = yield

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

@hookimpl(wrapper=True, tryfirst=True)
def pytest_collection_modifyitems(
self, items: list[nodes.Item]
) -> Generator[None, None, None]:
def pytest_collection_modifyitems(self, items: list[nodes.Item]) -> Generator[None]:
res = yield

if self.active:
Expand Down
22 changes: 11 additions & 11 deletions src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _reopen_stdio(f, mode):


@hookimpl(wrapper=True)
def pytest_load_initial_conftests(early_config: Config) -> Generator[None, None, None]:
def pytest_load_initial_conftests(early_config: Config) -> Generator[None]:
ns = early_config.known_args_namespace
if ns.capture == "fd":
_windowsconsoleio_workaround(sys.stdout)
Expand Down Expand Up @@ -818,7 +818,7 @@ def resume_fixture(self) -> None:
# Helper context managers

@contextlib.contextmanager
def global_and_fixture_disabled(self) -> Generator[None, None, None]:
def global_and_fixture_disabled(self) -> Generator[None]:
"""Context manager to temporarily disable global and current fixture capturing."""
do_fixture = self._capture_fixture and self._capture_fixture._is_started()
if do_fixture:
Expand All @@ -835,7 +835,7 @@ def global_and_fixture_disabled(self) -> Generator[None, None, None]:
self.resume_fixture()

@contextlib.contextmanager
def item_capture(self, when: str, item: Item) -> Generator[None, None, None]:
def item_capture(self, when: str, item: Item) -> Generator[None]:
self.resume_global_capture()
self.activate_fixture()
try:
Expand Down Expand Up @@ -870,17 +870,17 @@ def pytest_make_collect_report(
return rep

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

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

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

Expand Down Expand Up @@ -962,7 +962,7 @@ def _is_started(self) -> bool:
return False

@contextlib.contextmanager
def disabled(self) -> Generator[None, None, None]:
def disabled(self) -> Generator[None]:
"""Temporarily disable capturing while inside the ``with`` block."""
capmanager: CaptureManager = self.request.config.pluginmanager.getplugin(
"capturemanager"
Expand All @@ -975,7 +975,7 @@ def disabled(self) -> Generator[None, None, None]:


@fixture
def capsys(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
def capsys(request: SubRequest) -> Generator[CaptureFixture[str]]:
r"""Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.

The captured output is made available via ``capsys.readouterr()`` method
Expand Down Expand Up @@ -1003,7 +1003,7 @@ def test_output(capsys):


@fixture
def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]:
r"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.

The captured output is made available via ``capsysbinary.readouterr()``
Expand Down Expand Up @@ -1031,7 +1031,7 @@ def test_output(capsysbinary):


@fixture
def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
def capfd(request: SubRequest) -> Generator[CaptureFixture[str]]:
r"""Enable text capturing of writes to file descriptors ``1`` and ``2``.

The captured output is made available via ``capfd.readouterr()`` method
Expand Down Expand Up @@ -1059,7 +1059,7 @@ def test_system_echo(capfd):


@fixture
def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]:
r"""Enable bytes capturing of writes to file descriptors ``1`` and ``2``.

The captured output is made available via ``capfd.readouterr()`` method
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def _is_mocked(obj: object) -> bool:


@contextmanager
def _patch_unwrap_mock_aware() -> Generator[None, None, None]:
def _patch_unwrap_mock_aware() -> Generator[None]:
"""Context manager which replaces ``inspect.unwrap`` with a version
that's aware of mock objects and doesn't recurse into them."""
real_unwrap = inspect.unwrap
Expand Down
22 changes: 10 additions & 12 deletions src/_pytest/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,7 @@ def set_level(self, level: int | str, logger: str | None = None) -> None:
self._initial_disabled_logging_level = initial_disabled_logging_level

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

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


@fixture
def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture, None, None]:
def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture]:
"""Access and control log capturing.

Captured logs are available through the following properties/methods::
Expand Down Expand Up @@ -776,15 +774,15 @@ def _log_cli_enabled(self) -> bool:
return True

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

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

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

with catching_logs(self.log_cli_handler, level=self.log_cli_level):
Expand Down Expand Up @@ -813,7 +811,7 @@ def pytest_runtest_logstart(self) -> None:
def pytest_runtest_logreport(self) -> None:
self.log_cli_handler.set_when("logreport")

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

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

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

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

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

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

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

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

with catching_logs(self.log_cli_handler, level=self.log_cli_level):
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@fixture
def monkeypatch() -> Generator[MonkeyPatch, None, None]:
def monkeypatch() -> Generator[MonkeyPatch]:
"""A convenient fixture for monkey-patching.

The fixture provides these methods to modify objects, dictionaries, or
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self) -> None:

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

Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def pytester(


@fixture
def _sys_snapshot() -> Generator[None, None, None]:
def _sys_snapshot() -> Generator[None]:
snappaths = SysPathsSnapshot()
snapmods = SysModulesSnapshot()
yield
Expand All @@ -500,7 +500,7 @@ def _sys_snapshot() -> Generator[None, None, None]:


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

config = get_config()
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@
if setup_module is None and teardown_module is None:
return

def xunit_setup_module_fixture(request) -> Generator[None, None, None]:
def xunit_setup_module_fixture(request) -> Generator[None]:
module = request.module
if setup_module is not None:
_call_with_optional_argument(setup_module, module)
Expand Down Expand Up @@ -600,7 +600,7 @@
if setup_function is None and teardown_function is None:
return

def xunit_setup_function_fixture(request) -> Generator[None, None, None]:
def xunit_setup_function_fixture(request) -> Generator[None]:

Check warning on line 603 in src/_pytest/python.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/python.py#L603

Added line #L603 was not covered by tests
if request.instance is not None:
# in this case we are bound to an instance, so we need to let
# setup_method handle this
Expand Down Expand Up @@ -781,7 +781,7 @@
if setup_class is None and teardown_class is None:
return

def xunit_setup_class_fixture(request) -> Generator[None, None, None]:
def xunit_setup_class_fixture(request) -> Generator[None]:
cls = request.cls
if setup_class is not None:
func = getimfunc(setup_class)
Expand Down Expand Up @@ -814,7 +814,7 @@
if setup_method is None and teardown_method is None:
return

def xunit_setup_method_fixture(request) -> Generator[None, None, None]:
def xunit_setup_method_fixture(request) -> Generator[None]:
instance = request.instance
method = request.function
if setup_method is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


@fixture
def recwarn() -> Generator[WarningsRecorder, None, None]:
def recwarn() -> Generator[WarningsRecorder]:
"""Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.

See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def pytest_runtest_setup(item: Item) -> None:


@hookimpl(wrapper=True)
def pytest_runtest_call(item: Item) -> Generator[None, None, None]:
def pytest_runtest_call(item: Item) -> Generator[None]:
xfailed = item.stash.get(xfailed_key, None)
if xfailed is None:
item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None:
@hookimpl(wrapper=True)
def pytest_sessionfinish(
self, session: Session, exitstatus: int | ExitCode
) -> Generator[None, None, None]:
) -> Generator[None]:
result = yield
self._tw.line("")
summary_exit_codes = (
Expand All @@ -914,7 +914,7 @@ def pytest_sessionfinish(
return result

@hookimpl(wrapper=True)
def pytest_terminal_summary(self) -> Generator[None, None, None]:
def pytest_terminal_summary(self) -> Generator[None]:
self.summary_errors()
self.summary_failures()
self.summary_xfailures()
Expand Down
8 changes: 4 additions & 4 deletions src/_pytest/threadexception.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __exit__(
del self.args


def thread_exception_runtest_hook() -> Generator[None, None, None]:
def thread_exception_runtest_hook() -> Generator[None]:
with catch_threading_exception() as cm:
try:
yield
Expand All @@ -83,15 +83,15 @@ def thread_exception_runtest_hook() -> Generator[None, None, None]:


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


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


@pytest.hookimpl(wrapper=True, tryfirst=True)
def pytest_runtest_teardown() -> Generator[None, None, None]:
def pytest_runtest_teardown() -> Generator[None]:
yield from thread_exception_runtest_hook()
2 changes: 1 addition & 1 deletion src/_pytest/tmpdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path:
@fixture
def tmp_path(
request: FixtureRequest, tmp_path_factory: TempPathFactory
) -> Generator[Path, None, None]:
) -> Generator[Path]:
"""Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def process_teardown_exceptions() -> None:

def unittest_setup_class_fixture(
request: FixtureRequest,
) -> Generator[None, None, None]:
) -> Generator[None]:
cls = request.cls
if _is_skipped(cls):
reason = cls.__unittest_skip_why__
Expand Down Expand Up @@ -178,7 +178,7 @@ def _register_unittest_setup_method_fixture(self, cls: type) -> None:

def unittest_setup_method_fixture(
request: FixtureRequest,
) -> Generator[None, None, None]:
) -> Generator[None]:
self = request.instance
if _is_skipped(self):
reason = self.__unittest_skip_why__
Expand Down
Loading
Loading