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 --- tasks.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 46cd57c1..d272a34b 100644 --- a/tasks.py +++ b/tasks.py @@ -1,5 +1,6 @@ # # coding=utf-8 +# flake8: noqa E302 """Development related tasks to be run with 'invoke'. Make sure you satisfy the following Python module requirements if you are trying to publish a release to PyPI: -- cgit v1.2.1 From 9d90c1eb57c62ba1fcd8e470fa2e27248e1e9064 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 6 Dec 2018 09:20:39 -0500 Subject: Added flake8 invoke task to make it easy for developers to run flake8 locally identical to how it gets run during a PR --- tasks.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index d272a34b..d5f5976b 100644 --- a/tasks.py +++ b/tasks.py @@ -227,3 +227,11 @@ def pypi_test(context): "Build and upload a distribution to https://test.pypi.org" context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*') namespace.add_task(pypi_test) + + +# Flake8 - linter and tool for style guide enforcement and linting +@invoke.task +def flake8(context): + "Run flake8 linter and tool for style guide enforcement" + context.run("flake8 --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics") +namespace.add_task(flake8) -- cgit v1.2.1