From 01c8ef83756a80f57ebe08879f3dc510253265fb Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Wed, 29 Jul 2020 12:13:01 +0200 Subject: [PATCH] mgr/cephadm: Introduce tox and autopep8 This PR introduces tox and autopep8 to format the Python code according to PEP8. It does NOT include any lint related things. Signed-off-by: Volker Theile (cherry picked from commit 7d8a3b60321da10af6f4557a9d69eda09ca2c620) Conflicts: src/pybind/mgr/tox.ini --- src/pybind/mgr/requirements-fix.txt | 1 + src/pybind/mgr/tox.ini | 40 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/pybind/mgr/requirements-fix.txt diff --git a/src/pybind/mgr/requirements-fix.txt b/src/pybind/mgr/requirements-fix.txt new file mode 100644 index 0000000000000..caaefd789ec55 --- /dev/null +++ b/src/pybind/mgr/requirements-fix.txt @@ -0,0 +1 @@ +autopep8; python_version >= '3' diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 2ef106ef50cb8..d197a72fd4d11 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -1,8 +1,30 @@ [tox] -envlist = py3, mypy +envlist = + py3, + mypy, + test, + fix skipsdist = true requires = cython +[flake8] +max-line-length = 100 +exclude = + .tox, + .vagrant, + __pycache__, + *.pyc, + templates, + .eggs + +[autopep8] +addopts = + --max-line-length {[flake8]max-line-length} + --exclude "{[flake8]exclude}" + --in-place + --recursive + --ignore-local-config + [testenv] setenv = UNITTEST = true @@ -26,7 +48,8 @@ deps = cython -rrequirements.txt mypy==0.770 -commands = mypy --config-file=../../mypy.ini \ +commands = + mypy --config-file=../../mypy.ini \ cephadm/module.py \ mgr_module.py \ dashboard/module.py \ @@ -37,3 +60,16 @@ commands = mypy --config-file=../../mypy.ini \ rook/module.py \ test_orchestrator/module.py \ volumes/__init__.py + +[testenv:test] +setenv = {[testenv]setenv} +deps = {[testenv]deps} +commands = {[testenv]commands} + +[testenv:fix] +basepython = python3 +deps = -rrequirements-fix.txt +commands = + python --version + autopep8 {[autopep8]addopts} {posargs: \ + cephadm/} -- 2.39.5