From d11f5b9d16e1d5b30c63a1bf2801c459492cf6e4 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 14 Feb 2018 23:10:41 +0100 Subject: [PATCH] Use flake8 to find Python syntax errors or undefined names --- .travis.yml | 8 +++++++- sshuttle/assembler.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28e7a80..6fbfaa2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,13 @@ python: - pypy install: - - travis_retry pip install -q pytest mock + - travis_retry pip install -q flake8 pytest mock + +before_script: + # stop the build if there are Python syntax errors or undefined names. + - if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics; fi + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide. + - if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics; fi script: - PYTHONPATH=. py.test diff --git a/sshuttle/assembler.py b/sshuttle/assembler.py index 7b81ef1..06ff672 100644 --- a/sshuttle/assembler.py +++ b/sshuttle/assembler.py @@ -2,9 +2,9 @@ import sys import zlib import imp +verbosity = verbosity # noqa: F821 must be a previously defined global z = zlib.decompressobj() while 1: - global verbosity name = sys.stdin.readline().strip() if name: name = name.decode("ASCII") @@ -22,7 +22,7 @@ while 1: setattr(sys.modules[parent], parent_name, module) code = compile(content, name, "exec") - exec(code, module.__dict__) # nosec + exec(code, module.__dict__) # nosec sys.modules[name] = module else: break