Skip to content

Commit

Permalink
run-linters: Add --errors-only mode
Browse files Browse the repository at this point in the history
Running the linters during the Ubuntu package build or in the
autopkgtest is not wanted because newer linter versions can introduce
new checks that can cause the build/autopkgtest to fail.

So add an `--errors-only` mode that skips all formatting checks, but
keeps the checks that can detect real errors. So run pylint with
`--errors-only` and mypy.

Bug: https://launchpad.net/bugs/2028881
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
  • Loading branch information
bdrung committed Jul 28, 2023
1 parent bed5288 commit 0672bcd
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/run-linters
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,20 @@ run_pylint() {
return
fi
echo "Running pylint..."
pylint -j 0 ${PYTHON_FILES} ${PYTHON_SCRIPTS}
pylint -j 0 "$@" ${PYTHON_FILES} ${PYTHON_SCRIPTS}
}

run_black
run_isort
run_pycodestyle
run_pydocstyle
run_pyflakes
run_mypy
run_pylint
check_hardcoded_names
if test "${1-}" = "--errors-only"; then
# Run only linters that can detect real errors (ignore formatting)
run_mypy
run_pylint --errors-only
else
run_black
run_isort
run_pycodestyle
run_pydocstyle
run_pyflakes
run_mypy
run_pylint
check_hardcoded_names
fi

0 comments on commit 0672bcd

Please sign in to comment.