1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/script/lint
Ville Skyttä bb37bc32e3
Always run flake8 through pre-commit, and with doctests (#28490)
* Enable flake8 doctests everywhere

* Always run flake8 through pre-commit
2019-11-06 21:38:00 +02:00

29 lines
816 B
Bash
Executable File

#!/bin/sh
# Execute lint to spot code mistakes.
cd "$(dirname "$0")/.."
export files="$(git diff $(git merge-base upstream/dev HEAD) --diff-filter=d --name-only | grep -e '\.py$')"
echo '================================================='
echo '= FILES CHANGED ='
echo '================================================='
if [ -z "$files" ] ; then
echo "No python file changed. Rather use: tox -e lint\n"
exit
fi
printf "%s\n" $files
echo "================"
echo "LINT with flake8"
echo "================"
pre-commit run flake8 --files $files
echo "================"
echo "LINT with pylint"
echo "================"
pylint_files=$(echo "$files" | grep -v '^tests.*')
if [ -z "$pylint_files" ] ; then
echo "Only test files changed. Skipping\n"
exit
fi
pylint $pylint_files
echo