From fc0c37efc1cdd260eedc701bba2f01d0c015add4 Mon Sep 17 00:00:00 2001 From: Jiri Kucera Date: Mon, 20 Jan 2020 10:10:14 +0100 Subject: [PATCH] Wrap flake8 Wrapping flake8 give a possibility to a user to dissable flake8 via setting environment variable in config.sh. --- .travis/config.sh | 4 ++++ .travis/runflake8.sh | 34 ++++++++++++++++++++++++++++++++++ tox.ini | 6 ++++-- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 .travis/runflake8.sh diff --git a/.travis/config.sh b/.travis/config.sh index 2e3f401..992ed07 100644 --- a/.travis/config.sh +++ b/.travis/config.sh @@ -22,5 +22,9 @@ # - RUN_BLACK_EXCLUDE # - RUN_BLACK_DISABLED # +# * .travis/runflake8.sh: +# +# - RUN_FLAKE8_DISABLED +# export LSR_MOLECULE_DEPS='-rmolecule_requirements.txt' diff --git a/.travis/runflake8.sh b/.travis/runflake8.sh new file mode 100755 index 0000000..3cecdca --- /dev/null +++ b/.travis/runflake8.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +# A shell wrapper around flake8. The purpose of this wrapper is to get to user +# an opportunity to disable running flake8 via config.sh. + +# The first script argument is a path to Python interpreter, the rest of +# arguments are passed to flake8. + +# Environment variables: +# +# RUN_FLAKE8_DISABLED +# if set to an arbitrary non-empty value, flake8 will be not executed + +set -e + +ME=$(basename $0) +SCRIPTDIR=$(readlink -f $(dirname $0)) + +. ${SCRIPTDIR}/utils.sh +. ${SCRIPTDIR}/config.sh + +if [[ "${RUN_FLAKE8_DISABLED}" ]]; then + lsr_info "${ME}: flake8 is disabled. Skipping." + exit 0 +fi + +# Sanitize path in case if running within tox (see +# https://github.com/tox-dev/tox/issues/1463): +ENVPYTHON=$(readlink -f $1) +shift + +set -x +${ENVPYTHON} -m flake8 "$@" diff --git a/tox.ini b/tox.ini index 1fe8eb6..480d067 100644 --- a/tox.ini +++ b/tox.ini @@ -153,11 +153,13 @@ commands = [testenv:flake8] envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7} basepython = python2.7 +passenv = RUN_FLAKE8_* deps = flake8>=3.5 -whitelist_externals = flake8 +whitelist_externals = + {[base]whitelist_externals} commands = - flake8 --statistics {posargs} . + bash {toxinidir}/.travis/runflake8.sh {envpython} --statistics {posargs} . [testenv:coveralls] envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:coveralls}