From 6c692335df8f30023a7ee5d99a9d93443b3035c2 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Wed, 26 Jan 2022 11:47:19 -0700 Subject: [PATCH 1/2] fix tox -p, remove unnecessary deps --- CONTRIBUTING.rst | 2 +- tox.ini | 52 +++++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index aa09c61e19c..cbd1ce3bb0f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -19,7 +19,7 @@ Before any pull request can be accepted, you must do the following: `tools/.github-cla-signers`_ * Add or update any `unit tests`_ accordingly * Add or update any `integration tests`_ (if applicable) -* Format code (using black and isort) with `tox -e format` +* Format code (using black and isort) with `tox -e do_format` * Ensure unit tests and linting pass using `tox`_ * Submit a PR against the `main` branch of the `cloud-init` repository diff --git a/tox.ini b/tox.ini index 52849557b5f..543bc1fdf6d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,39 +9,51 @@ setenv = passenv= PYTEST_ADDOPTS -[flake_env] -envdir = {toxworkdir}/.flake_env -deps = - flake8==3.9.2 - pylint==2.11.1 - black==21.12b0 - isort==5.10.1 - -r{toxinidir}/test-requirements.txt - -r{toxinidir}/integration-requirements.txt +[version] +flake8==3.9.2 +pylint==2.11.1 +black==21.12b0 +isort==5.10.1 [testenv:flake8] -envdir = {[flake_env]envdir} -deps = {[flake_env]deps} +deps = + flake8=={[version]flake8} commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} [testenv:pylint] -envdir = {[flake_env]envdir} -deps = {[flake_env]deps} +deps = + pylint=={[version]pylint} + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/integration-requirements.txt commands = {envpython} -m pylint {posargs:cloudinit tests tools} [testenv:black] -envdir = {[flake_env]envdir} -deps = {[flake_env]deps} +deps = + black=={[version]black} commands = {envpython} -m black . --check [testenv:isort] -envdir = {[flake_env]envdir} -deps = {[flake_env]deps} +deps = + isort=={[version]isort} commands = {envpython} -m isort . --check-only -[testenv:format] -envdir = {[flake_env]envdir} -deps = {[flake_env]deps} +[testenv:check_format] +envlist = flake8, pylint, black, isort +deps = + flake8=={[version]flake8} + pylint=={[version]pylint} + black=={[version]black} + isort=={[version]isort} + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/integration-requirements.txt +commands = + {envpython} -m isort . + {envpython} -m black . + +[testenv:do_format] +deps = + black=={[version]black} + isort=={[version]isort} commands = {envpython} -m isort . {envpython} -m black . From 8ccc3f9eba7fe815bac7da7e973b0f18c991b6b0 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Mon, 31 Jan 2022 14:21:45 -0700 Subject: [PATCH 2/2] fix check_format, other nits --- tox.ini | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tox.ini b/tox.ini index 543bc1fdf6d..5037fa6999a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ setenv = passenv= PYTEST_ADDOPTS -[version] +[format_deps] flake8==3.9.2 pylint==2.11.1 black==21.12b0 @@ -17,43 +17,44 @@ isort==5.10.1 [testenv:flake8] deps = - flake8=={[version]flake8} + flake8=={[format_deps]flake8} commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} [testenv:pylint] deps = - pylint=={[version]pylint} + pylint=={[format_deps]pylint} -r{toxinidir}/test-requirements.txt -r{toxinidir}/integration-requirements.txt commands = {envpython} -m pylint {posargs:cloudinit tests tools} [testenv:black] deps = - black=={[version]black} + black=={[format_deps]black} commands = {envpython} -m black . --check [testenv:isort] deps = - isort=={[version]isort} + isort=={[format_deps]isort} commands = {envpython} -m isort . --check-only [testenv:check_format] -envlist = flake8, pylint, black, isort deps = - flake8=={[version]flake8} - pylint=={[version]pylint} - black=={[version]black} - isort=={[version]isort} + flake8=={[format_deps]flake8} + pylint=={[format_deps]pylint} + black=={[format_deps]black} + isort=={[format_deps]isort} -r{toxinidir}/test-requirements.txt -r{toxinidir}/integration-requirements.txt commands = - {envpython} -m isort . - {envpython} -m black . + {[testenv:black]commands} + {[testenv:isort]commands} + {[testenv:flake8]commands} + {[testenv:pylint]commands} [testenv:do_format] deps = - black=={[version]black} - isort=={[version]isort} + black=={[format_deps]black} + isort=={[format_deps]isort} commands = {envpython} -m isort . {envpython} -m black .