From 001112df9fcce34b5aa2e8cc4527d57a72712128 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Tue, 2 Oct 2018 16:46:01 -0500 Subject: [PATCH] Add zuul job to run tox-format environment for executing black and isort This will allow us to have more consistent and clean code. Change-Id: I8a49053d016c52b7b44136a6a8f36f9ad12675c3 --- .zuul.yaml | 2 ++ pyproject.toml | 2 ++ setup.cfg | 22 ++++++++++++++++++++++ test-requirements.txt | 2 ++ tox.ini | 14 ++++---------- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 pyproject.toml diff --git a/.zuul.yaml b/.zuul.yaml index 9147299..f222942 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,7 +1,9 @@ - project: check: jobs: + - tox-format - tox-pep8 gate: jobs: + - tox-format - tox-pep8 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..55ec8d7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 120 diff --git a/setup.cfg b/setup.cfg index 13d7089..2a8d1ea 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,3 +53,25 @@ universal = 1 [pbr] skip_authors = True skip_changelog = True + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. +# E741, short ambiguous variable names +# H106 Don’t put vim configuration in source files +# H203 Use assertIs(Not)None to check for None +max-line-length = 120 +ignore = E123,E125,E741 +enable-extensions=H106,H203 +show-source = True +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build + +[isort] +known_first_party = ara +default_section = THIRDPARTY +skip = build,.git,.tox,.cache,.venv +not_skip = __init__.py +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +line_length=88 diff --git a/test-requirements.txt b/test-requirements.txt index 97b7674..d6b4edf 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,3 +3,5 @@ coverage flake8 sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 sphinx-rtd-theme +black==18.9b0 ; python_version >= '3.6' # Exact version for prerelease +isort diff --git a/tox.ini b/tox.ini index f1d522b..c03eede 100644 --- a/tox.ini +++ b/tox.ini @@ -22,13 +22,7 @@ commands = flake8 ara bandit -r ara -[flake8] -# E123, E125 skipped as they are invalid PEP-8. -# E741, short ambiguous variable names -# H106 Don’t put vim configuration in source files -# H203 Use assertIs(Not)None to check for None -max-line-length = 120 -ignore = E123,E125,E741 -enable-extensions=H106,H203 -show-source = True -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build +[testenv:format] +commands = + black --diff --check ara + isort --recursive --check-only --diff --virtual-env {envdir} ara