From c689e74fed45bf1a7b2908defc343d35f31dff71 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 6 Dec 2018 01:24:19 -0500 Subject: Fix flake8 issues This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes. Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline: * flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first. One flake8 error is being ignored entirely: * E252 missing whitespace around parameter equals * ignored because it doesn't correctly deal with default argument values after a type hint A few flake8 errors are being selectively ignored in certain files: * C901 fuction is too complex * ignored in argparse_completer.py because the complex code is an override of argparse complexity * E302 expected 2 blank lines after ... * ignored in all unit test files for convenience * F401 module imported but unused * ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility * F821 undefined name * ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined --- examples/scripts/arg_printer.py | 2 +- examples/scripts/conditional.py | 2 +- examples/scripts/script.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/scripts') diff --git a/examples/scripts/arg_printer.py b/examples/scripts/arg_printer.py index 848dcf99..19f6dd3f 100755 --- a/examples/scripts/arg_printer.py +++ b/examples/scripts/arg_printer.py @@ -5,4 +5,4 @@ import sys print("Running Python script {!r} which was called with {} arguments".format(os.path.basename(sys.argv[0]), len(sys.argv) - 1)) for i, arg in enumerate(sys.argv[1:]): - print("arg {}: {!r}".format(i+1, arg)) + print("arg {}: {!r}".format(i + 1, arg)) diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py index d7ee5ea2..faac3947 100644 --- a/examples/scripts/conditional.py +++ b/examples/scripts/conditional.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa F821 """ This is a Python script intended to be used with the "python_scripting.py" cmd2 example application. @@ -12,7 +13,6 @@ application instance. import os import sys - if len(sys.argv) > 1: directory = sys.argv[1] print('Using specified directory: {!r}'.format(directory)) diff --git a/examples/scripts/script.py b/examples/scripts/script.py index 3f60c8fb..5195b8cc 100644 --- a/examples/scripts/script.py +++ b/examples/scripts/script.py @@ -4,4 +4,3 @@ Trivial example of a Python script which can be run inside a cmd2 application. """ print("This is a python script running ...") - -- cgit v1.2.1