From 9e270f46d2ea09c97797e6ee3a003b34856ec5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 6 Nov 2026 12:38:38 -0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=8E=A8=20Drop=20the=20unused=20core?= =?UTF-8?q?=20config=20hook=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pluggy passes a hook implementation only the arguments it names, so the plugin no longer has to accept the core configuration set it never reads. That also removes the two suppression comments, which ruff rewrote into a line flake8 now rejects as too long. Assisted-by: LLM --- src/tox_plugins/pre_commit/_plugin.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tox_plugins/pre_commit/_plugin.py b/src/tox_plugins/pre_commit/_plugin.py index 2402bcc..fd0e4ad 100644 --- a/src/tox_plugins/pre_commit/_plugin.py +++ b/src/tox_plugins/pre_commit/_plugin.py @@ -13,7 +13,6 @@ if _t.TYPE_CHECKING: from collections import abc as _c # noqa: WPS347 - from tox.config.sets import ConfigSet from tox.session.state import State @@ -37,13 +36,9 @@ def tox_extend_envs() -> _c.Iterable[str]: @impl -def tox_add_core_config( - core_conf: ConfigSet, # ruff: ignore[unused-function-argument] # pylint: disable=unused-argument - state: State, -) -> None: +def tox_add_core_config(state: State) -> None: """Inject default configuration for the pre-commit environment. - :param core_conf: The core tox configuration set (unused). :param state: The tox session state to inject environments into. """ pos_args = state.conf.pos_args(to_path=None) From 83b45f52f2e076a346c148fd4633dc9fccd15689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 6 Nov 2026 12:38:38 -0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A7=AA=20Request=20the=20isolation=20?= =?UTF-8?q?fixture=20via=20usefixtures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ruff now flags autouse fixtures. Listing the fixture in pytest's `usefixtures` setting keeps it applied to every test. That setting starts it before tox's own environment check, so the fixture now keeps its own monkeypatch and restores the environment after that check. Assisted-by: LLM --- pytest.ini | 3 +++ tests/conftest.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pytest.ini b/pytest.ini index dd64b72..bfaa4bc 100644 --- a/pytest.ini +++ b/pytest.ini @@ -77,4 +77,7 @@ norecursedirs = testpaths = tests/ +usefixtures = + _isolate_user_environment + xfail_strict = true diff --git a/tests/conftest.py b/tests/conftest.py index 02fd59e..055e918 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,17 +3,26 @@ from __future__ import annotations import os +import typing as _t import pytest +if _t.TYPE_CHECKING: + from collections import abc as _c # noqa: WPS347 + + pytest_plugins = ('tox.pytest',) -@pytest.fixture(autouse=True) -def _isolate_user_environment(monkeypatch: pytest.MonkeyPatch) -> None: +@pytest.fixture +def _isolate_user_environment() -> _c.Iterator[None]: """Isolate the tests from the user's tox configuration. - :param monkeypatch: Pytest's environment-manipulation fixture. + :yields: Control to the test while the user configuration is hidden. """ - monkeypatch.setenv('TOX_USER_CONFIG_FILE', os.devnull) + # `usefixtures` starts this before tox's environment check, so its own + # monkeypatch must outlive that check rather than share the test's one + with pytest.MonkeyPatch.context() as monkeypatch: + monkeypatch.setenv('TOX_USER_CONFIG_FILE', os.devnull) + yield From d8b68fb6b81af1193566d5a853e2817f3eaa87c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 6 Nov 2026 12:38:38 -0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A7=20Keep=20pylint=20on=20pytest?= =?UTF-8?q?=20below=209.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pylint-pytest crashes on any module under pytest 9.2, which broke the pylint hook. The constraint stays until the plugin supports it: https://github.com/pylint-dev/pylint-pytest/issues/163 Assisted-by: LLM --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f40932..998ae76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -291,6 +291,9 @@ repos: additional_dependencies: - covdefaults # needed by pylint-pytest due to pytest-cov loading coverage - pylint-pytest ~= 2.0.0a0 + # pylint-pytest crashes on pytest 9.2: + # https://github.com/pylint-dev/pylint-pytest/issues/163 + - pytest < 9.2 - pytest-cov # needed by pylint-pytest since it picks up pytest's args - pytest-xdist # needed by pylint-pytest since it picks up pytest's args - pytest-subtests From 26c5f6bfd8432cbd69caed0ad82c1d4e3db88efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 6 Nov 2026 14:21:34 -0800 Subject: [PATCH 4/4] Pass the Codecov token to the notification step --- .github/workflows/ci-cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 6391838..7908173 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -596,6 +596,7 @@ jobs: fail_ci_if_error: >- ${{ fromJSON(needs.pre-setup.outputs.is-upstream-repository) }} run_command: send-notifications + token: ${{ secrets.CODECOV_TOKEN }} publish-pypi: name: >-