Files
python-pytest-flake8/support-pytest-9.patch
2025-12-16 12:45:11 +11:00

43 lines
1.5 KiB
Diff

Sourced from https://github.com/OpenIndiana/oi-userland/pull/19860/commits/0d06abedf17256d1f2c89086acc05cfa53dbc647
https://github.com/coherent-oss/pytest-flake8/issues/5
--- pytest_flake8-1.3.0/pytest_flake8.py.orig
+++ pytest_flake8-1.3.0/pytest_flake8.py
@@ -4,6 +4,7 @@
import re
from contextlib import redirect_stdout, redirect_stderr
from io import BytesIO, TextIOWrapper
+from fnmatch import fnmatch
from flake8.main import application
@@ -59,11 +60,11 @@
config._flake8mtimes = config.cache.get(HISTKEY, {})
-def pytest_collect_file(file_path, path, parent):
+def pytest_collect_file(file_path, parent):
"""Filter files down to which ones should be checked."""
config = parent.config
if config.option.flake8 and file_path.suffix in config._flake8exts:
- flake8ignore = config._flake8ignore(path)
+ flake8ignore = config._flake8ignore(file_path)
if flake8ignore is not None:
item = Flake8File.from_parent(
parent,
@@ -203,7 +204,12 @@
def __call__(self, path):
l = [] # noqa: E741
for glob, ignlist in self.ignores:
- if not glob or path.fnmatch(glob):
+ mpath = path
+ if glob and '/' in glob:
+ glob = "*" + glob
+ else:
+ mpath = str(path).split("/")[-1]
+ if not glob or fnmatch(mpath, glob):
if ignlist is None:
return None
l.extend(ignlist)