From ffa7d55448c6a7e3e788014977a707112a376c64 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Fri, 20 May 2016 11:04:59 -0700 Subject: [PATCH] Setup a tox pep8 check and update test-requirements.txt Add a tox pep8 check. Fix PEP8 error in tools/list_ptls.py Update test-requirements.txt for libraries used. Change-Id: I179036ebbce555586a711677f45337b364d4847f --- test-requirements.txt | 3 +++ test_tools/flake8wrap.sh | 20 ++++++++++++++++++++ tools/list_ptls.py | 3 ++- tox.ini | 17 +++++++++++++++-- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 test_tools/flake8wrap.sh diff --git a/test-requirements.txt b/test-requirements.txt index 2ac94527..4217724c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,4 @@ +hacking<0.11,>=0.10.0 +PyYAML>=3.1.0 # MIT +requests>=2.10.0 # Apache-2.0 yaml2ical>=0.6.1 diff --git a/test_tools/flake8wrap.sh b/test_tools/flake8wrap.sh new file mode 100755 index 00000000..531b407d --- /dev/null +++ b/test_tools/flake8wrap.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# 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 +# + +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 diff --git a/tools/list_ptls.py b/tools/list_ptls.py index c614e737..c944be4f 100644 --- a/tools/list_ptls.py +++ b/tools/list_ptls.py @@ -22,6 +22,7 @@ import yaml PROJECTS_LIST = "http://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml" # noqa + def main(): parser = argparse.ArgumentParser() parser.add_argument( @@ -57,7 +58,7 @@ def main(): initial_indent=args.msg + ' ', subsequent_indent=args.msg + ' ', width=80, - )) + )) if __name__ == '__main__': diff --git a/tox.ini b/tox.ini index 4d837926..64f0b582 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = ical +envlist = ical,pep8 minversion = 1.6 skipsdist = True @@ -7,12 +7,12 @@ skipsdist = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/test-requirements.txt -whitelist_externals = mkdir [testenv:venv] commands = {posargs} [testenv:ical] +whitelist_externals = mkdir commands = mkdir -p output/calendars yaml2ical -n "OpenStack Meetings" \ @@ -24,3 +24,16 @@ commands = [testenv:check] commands = python tools/check_channels.py -y meetings + +[testenv:pep8] +whitelist_externals = bash +commands = + bash test_tools/flake8wrap.sh {posargs} + +[flake8] +ignore = +exclude = .git,.tox +max-complexity = 14 + +[hacking] +import_exceptions =