File: pytest-pathlib-path.patch

package info (click to toggle)
pytest-pylint 0.21.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 232 kB
  • sloc: python: 638; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,814 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: =?utf-8?q?Michael_K=C3=A4ufl?= <michael-k@users.noreply.github.com>
Date: Mon, 4 Mar 2024 12:39:20 +0100
Subject: 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

Origin: upstream, https://github.com/carsongee/pytest-pylint/pull/193
Bug: https://github.com/carsongee/pytest-pylint/issues/192
Bug-Debian: https://bugs.debian.org/1122932
Last-Update: 2025-12-16
---
 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 fc5c50d..f33972b 100644
--- a/pytest_pylint/plugin.py
+++ b/pytest_pylint/plugin.py
@@ -220,16 +220,16 @@ class PylintPlugin:
         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