Add pre-commit configuration

'pre-commit' tool [1] provides an extensible way to configure hooks
which can be run automatically before each commit. That way we can make
sure that code send to review is passing base static analysis checks
like e.g. bandit, flake8 or hacking.

For now this is optional to use and not integrated in e.g. tox.ini file
but we can integrate it there too as next step.

[1] https://pre-commit.com/

Change-Id: I49efd39a93103d2e1888c9b641962280622ae60b
This commit is contained in:
Slawek Kaplonski 2024-04-27 09:32:11 +02:00
parent a0fb735b7e
commit 3db16a4f70
2 changed files with 9 additions and 0 deletions

View File

@ -45,6 +45,7 @@ disable=
unused-variable,
useless-super-delegation,
using-constant-test,
redundant-u-string-prefix,
# "C" Coding convention violations
consider-iterating-dictionary,
consider-using-enumerate,
@ -75,6 +76,8 @@ disable=
too-many-public-methods,
too-many-return-statements,
too-many-statements,
use-dict-literal,
super-with-arguments,
# new for python3 version of pylint
consider-using-set-comprehension,
unnecessary-pass,

View File

@ -39,6 +39,12 @@ run_pylint () {
echo "Running pylint..."
echo "You can speed this up by running it on 'HEAD~[0-9]' (e.g. HEAD~1, this change only)..."
echo ""
echo "Consider using the 'pre-commit' tool instead."
echo ""
echo " pip install --user pre-commit"
echo " pre-commit install --allow-missing-config"
echo ""
if [ -n "${files}" ]; then
pylint --rcfile=.pylintrc --output-format=colorized ${files}
else