interop/tools/flake8wrap.sh
Mark T. Voelker c8138d4fa5 Add pep8/flake8 checks, fix flake8 errors
We're starting to accumulate a number of python scripts in
various parts of the tree, and probably will continue to do so.
To make maintenance easier over time, we should have basic
pep8/flake8 checks in place for python code, as is best practice
elsewhere in the OpenStack project.  This patch adds basic checks
and corrects existing errors in our python scripts so that going
forward we can opt to gate on clean python code.

Change-Id: Ie32ee7a14ee608e12f42288e137a0849555b5ed8
2015-08-18 12:18:01 +00:00

22 lines
516 B
Bash
Executable File

#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
# Lovingly borrowed from openstack/nova.
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
exec flake8 "$@"
fi