From d4889503aa3fb1e351616d294a634b478e8e54e0 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 4 Mar 2024 12:06:11 +0100 Subject: [PATCH 1/2] fix: pytest 8 compat --- pytest_ruff/__init__.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/pytest_ruff/__init__.py b/pytest_ruff/__init__.py index dea76a7..eade02c 100644 --- a/pytest_ruff/__init__.py +++ b/pytest_ruff/__init__.py @@ -4,7 +4,12 @@ from ruff.__main__ import find_ruff_bin -from pytest_ruff._pytest_compat import get_stash, make_path_kwargs, set_stash +from pytest_ruff._pytest_compat import ( + get_stash, + make_path_kwargs, + set_stash, + PYTEST_VER, +) HISTKEY = "ruff/mtimes" @@ -26,15 +31,29 @@ def pytest_configure(config): set_stash(config, config.cache.get(HISTKEY, {})) -def pytest_collect_file(path, parent, fspath=None): - config = parent.config - if not config.option.ruff: - return +if PYTEST_VER >= (7, 0): - if path.ext != ".py": - return + def pytest_collect_file(file_path, parent, fspath=None): + config = parent.config + if not config.option.ruff: + return + + if file_path.suffix != ".py": + return + + return RuffFile.from_parent(parent, **make_path_kwargs(file_path)) + +else: + + def pytest_collect_file(path, parent, fspath=None): + config = parent.config + if not config.option.ruff: + return + + if path.ext != ".py": + return - return RuffFile.from_parent(parent, **make_path_kwargs(path)) + return RuffFile.from_parent(parent, **make_path_kwargs(path)) def pytest_sessionfinish(session, exitstatus): From 107ecfe97bb7076d4c2bf4248c7a51822c3ae3cf Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sun, 10 Mar 2024 13:44:01 +0100 Subject: [PATCH 2/2] Test on yanked pytest 8.1.0 --- tox.ini | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index fcbc6d6..6c5de3c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] isolated_build = true -envlist = py{38,39,310,311,312}-pytest{5,6,7,8},lint +envlist = py{38,39,310,311,312}-pytest{5,6,7,8,810,81},lint [testenv] allowlist_externals = poetry @@ -9,7 +9,10 @@ commands = pytest5: pip install "pytest<6" pytest6: pip install "pytest>=6,<7" pytest7: pip install "pytest>=7,<8" - pytest8: pip install "pytest>=8,<9" + pytest8: pip install "pytest>=8,<8.1" + # pytest 8.1.0 was yanked, but their "broken behaviour" will comeback soon + pytest810: pip install "pytest==8.1.0" + pytest81: pip install "pytest>=8.1,<9" # Disable ruff plugin to generate better coverage results poetry run pytest -p no:ruff -vvv --cov --cov-append --cov-report term --cov-report xml {posargs}