From 81f522336f5d540cc3cbdd98dce4529c080734ab Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 1 Dec 2015 08:07:42 +0100 Subject: [PATCH] Do PYTHONPATH shenanigans in run_pylint_on_tests. If we do it in tox.ini, there are two drawbacks: - We have more stuff in PYTHONPATH even if we don't when actually using qutebrowser. - The separator is platform specific, so we can't easily do this in a portable way in tox.ini. --- scripts/dev/run_pylint_on_tests.py | 14 ++++++++++++-- tox.ini | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/dev/run_pylint_on_tests.py b/scripts/dev/run_pylint_on_tests.py index 2ffa2974f..6c426561d 100644 --- a/scripts/dev/run_pylint_on_tests.py +++ b/scripts/dev/run_pylint_on_tests.py @@ -47,6 +47,7 @@ def main(): for fn in filenames: if os.path.splitext(fn)[1] == '.py': files.append(os.path.join(dirpath, fn)) + disabled = [ 'attribute-defined-outside-init', 'redefined-outer-name', @@ -56,11 +57,20 @@ def main(): # https://bitbucket.org/logilab/pylint/issue/511/ 'undefined-variable', ] + + toxinidir = sys.argv[1] + pythonpath = os.environ['PYTHONPATH'].split(os.pathsep) + [ + toxinidir, + ] + no_docstring_rgx = ['^__.*__$', '^setup$'] args = (['--disable={}'.format(','.join(disabled)), '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx))] + - sys.argv[1:] + files) - ret = subprocess.call(['pylint'] + args) + sys.argv[2:] + files) + env = os.environ.copy() + env['PYTHONPATH'] = os.pathsep.join(pythonpath) + + ret = subprocess.call(['pylint'] + args, env=env) return ret diff --git a/tox.ini b/tox.ini index 0d830327a..7b5da34d1 100644 --- a/tox.ini +++ b/tox.ini @@ -100,7 +100,7 @@ commands = basepython = python3 ignore_errors = true skip_install = true -setenv = PYTHONPATH={toxinidir}/scripts/dev:{toxinidir} +setenv = PYTHONPATH={toxinidir}/scripts/dev passenv = deps = {[testenv]deps} @@ -111,7 +111,7 @@ deps = commands = {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no - {envpython} scripts/dev/run_pylint_on_tests.py --output-format=colorized --reports=no + {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no [testenv:pylint-tip] basepython = python3