2019-11-14 19:27:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2021-01-01 00:10:26 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2019-2021 Patryk Obara <patryk.obara@gmail.com>
|
2019-11-14 19:27:22 +01:00
|
|
|
|
|
|
|
# This script exists only to easily run python static checker on all files in
|
|
|
|
# the repo. You can pass additional parameters to this script itself, e.g.:
|
|
|
|
#
|
|
|
|
# $ ./verify-python.sh --disable=<msg_ids>
|
2019-11-15 16:50:45 +01:00
|
|
|
#
|
|
|
|
# This script uses exclusively python3 version of pylint; most distributions
|
|
|
|
# provide it in a package pylint, but some call it pylint3 or python3-pylint.
|
|
|
|
|
|
|
|
set -e
|
2019-11-14 19:27:22 +01:00
|
|
|
|
2019-11-15 00:32:02 +01:00
|
|
|
list_python_files () {
|
2019-11-14 19:27:22 +01:00
|
|
|
git ls-files \
|
|
|
|
| xargs file \
|
|
|
|
| grep "Python script" \
|
2019-11-15 00:32:02 +01:00
|
|
|
| cut -d ':' -f 1
|
2019-11-14 19:27:22 +01:00
|
|
|
}
|
|
|
|
|
2019-11-15 00:32:02 +01:00
|
|
|
main () {
|
2019-11-15 16:50:45 +01:00
|
|
|
# Using "python3 -m pylint" to avoid using python2-only
|
|
|
|
# version of pylint by mistake.
|
|
|
|
python3 -m pylint --version >&2
|
2019-11-15 00:32:02 +01:00
|
|
|
echo "Checking files:" >&2
|
|
|
|
list_python_files >&2
|
|
|
|
local -r rc="$(git rev-parse --show-toplevel)/.pylint"
|
2019-11-15 16:50:45 +01:00
|
|
|
list_python_files | xargs -L 1000 python3 -m pylint --rcfile="$rc" "$@"
|
2019-11-15 00:32:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|