From 62457e8013df106116fb2a62c7c44870103ff393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Mon, 4 Mar 2024 12:39:20 +0100 Subject: [PATCH] Use `pathlib.Path` in plugin hooks Fixes compatibility with pytest 8.1, see - pytest-dev/pytest#8144 - https://docs.pytest.org/en/stable/changelog.html#id282 - https://docs.pytest.org/en/stable/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path Fixes carsongee/pytest-pylint#192 --- pytest_pylint/plugin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pytest_pylint/plugin.py b/pytest_pylint/plugin.py index dcab2ab..cdb60f5 100644 --- a/pytest_pylint/plugin.py +++ b/pytest_pylint/plugin.py @@ -220,16 +220,16 @@ def pytest_sessionfinish(self, session): if hasattr(session.config, "cache"): session.config.cache.set(HISTKEY, self.mtimes) - def pytest_collect_file(self, path, parent): + def pytest_collect_file(self, file_path, parent): """Collect files on which pylint should run""" - if path.ext != ".py": + if file_path.suffix != ".py": return None - rel_path = get_rel_path(path.strpath, str(parent.session.path)) + rel_path = file_path.relative_to(parent.session.path) if should_include_file( - rel_path, self.pylint_ignore, self.pylint_ignore_patterns + str(rel_path), self.pylint_ignore, self.pylint_ignore_patterns ): - item = PylintFile.from_parent(parent, path=Path(path), plugin=self) + item = PylintFile.from_parent(parent, path=file_path, plugin=self) else: return None