From 7d8a3b60321da10af6f4557a9d69eda09ca2c620 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 --- 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 00000000000..caaefd789ec --- /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 7ff959eefe4..b4541d7c226 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 @@ -27,7 +49,8 @@ deps = cython -rrequirements.txt mypy==0.782 -commands = mypy --config-file=../../mypy.ini \ +commands = + mypy --config-file=../../mypy.ini \ cephadm/module.py \ mgr_module.py \ dashboard/module.py \ @@ -38,3 +61,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