Fix: bandit pre-commit hook exclude regex 56/96556/1
authorGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 17 Jun 2021 08:20:59 +0000 (10:20 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 17 Jun 2021 08:20:59 +0000 (10:20 +0200)
The 'exclude' field in pre-commit hook is a regex, not a glob,
as it is advertised by pre-commit runtime warnings.
"tests/*" matches "tests", "tests/" or "tests//...///" but also any file
or folder, not necessarily at the root of the project, that contains
"tests" in its name.
The right regex to ignore the tests folder at project root is "^test/"

Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: I12d8c7e2205085ef1fb2fdf267d059112729d705

.pre-commit-config.yaml

index ca5cf7fbb4f65c9a3e61a06eb35a823f8fa143c3..e15b6fde97d51b5a9b24e9fd50208ff21b4de46a 100644 (file)
@@ -46,7 +46,7 @@ repos:
     hooks:
       - id: bandit
         # Bandit does not need to run on test code
-        exclude: tests/*
+        exclude: ^tests/
 
   - repo: https://github.com/pycqa/pydocstyle
     rev: 5.0.2