From: Simon Marchi Date: Tue, 5 Nov 2024 17:48:10 +0000 (-0500) Subject: setup.cfg: make flake8 scan *.py.in files X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=71ae6b8c17e5a5f37bbbea48deb4d635c7b028e6;p=babeltrace.git setup.cfg: make flake8 scan *.py.in files ... in order to scan `src/bindings/python/bt2/setup.py.in` (it is a valid Python program despite the name, the replacement tokens are only in strings). Make the pre-commit hooks run on this file as well (the technique is described somewhere here [1]). Doing so finds a small flake8 issue, fix it. [1] https://pre-commit.com/#filtering-files-with-types Change-Id: I1427d0d987884b72851741d6bb36620c5609ddb9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/13492 Tested-by: jenkins Reviewed-by: Michael Jeanson Reviewed-by: Philippe Proulx --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa852a30..4f967df6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,14 +8,20 @@ repos: rev: 23.12.1 hooks: - id: black + types: [file] + files: \.(py|py.in)$ exclude: '(src/bindings/python/bt2/bt2/local_typing.py|tests/utils/python/normand.py|tests/utils/python/tap/.*|tests/utils/python/typing/.*)' - repo: https://github.com/pycqa/flake8 rev: 7.1.1 hooks: - id: flake8 + types: [file] + files: \.(py|py.in)$ exclude: '(src/bindings/python/bt2/bt2/local_typing.py|tests/utils/python/normand.py|tests/utils/python/tap/.*|tests/utils/python/typing/.*)' - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort + types: [file] + files: \.(py|py.in)$ exclude: '(src/bindings/python/bt2/bt2/local_typing.py|tests/utils/python/normand.py|tests/utils/python/tap/.*|tests/utils/python/typing/.*)' diff --git a/setup.cfg b/setup.cfg index 331973f3..198ff183 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,8 @@ ignore = E501,W503,E203 # Has code to set up the DLL search path before imports. per-file-ignores = src/bindings/python/bt2/bt2/__init__.py:F401,E402 +filename = *.py, *.py.in + exclude = src/bindings/python/bt2/bt2/local_typing.py tests/utils/python/normand.py diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index 47f28506..411f715b 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -113,7 +113,7 @@ sysconfig.get_config_vars = our_get_config_vars # Returns 'True' when running on a MinGW system. def is_mingw(): - return sys.platform == "win32" and shutil.which("cygpath") != None + return sys.platform == "win32" and shutil.which("cygpath") is not None # On MinGW systems run 'cygpath -m' on 'path', on other systems return 'path' as-is.