]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix tox and add autopep8 'fix' env 29802/head
authorErnesto Puerta <epuertat@redhat.com>
Wed, 21 Aug 2019 17:39:41 +0000 (19:39 +0200)
committerErnesto Puerta <epuertat@redhat.com>
Fri, 23 Aug 2019 16:29:40 +0000 (18:29 +0200)
Fixes missing config settings around tox and flake8.

Adds toxenv 'fix' to automatically fix PEP8 issues. As we have disabled
so many PEP8 warnings, this currently fixes issues that may pass through
the toxenv 'lint'.

Fixes: https://tracker.ceph.com/issues/41379
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
src/pybind/mgr/dashboard/HACKING.rst
src/pybind/mgr/dashboard/requirements-lint.txt
src/pybind/mgr/dashboard/tox.ini

index d21dccb41c0eb4c7bc1c89cb53b43d3f1f5c11c4..b58820cd8805f0d41b7710eb8a7aeef9afe35b63 100644 (file)
@@ -575,7 +575,7 @@ Alternatively, you can use Python's native package installation method::
   $ pip install tox
   $ pip install coverage
 
-To run the tests, run ``run_tox.sh`` in the dashboard directory (where
+To run the tests, run ``src/script/run_tox.sh`` in the dashboard directory (where
 ``tox.ini`` is located)::
 
   ## Run Python 2+3 tests+lint commands:
@@ -595,6 +595,9 @@ You can also run tox instead of ``run_tox.sh``::
   ## Run Python 3 arbitrary command (e.g. 1 single test):
   $ tox -e py3 tests/test_rgw_client.py::RgwClientTest::test_ssl_verify
 
+Python files can be automatically fixed and formatted according to PEP8
+standards by using ``run_tox.sh --tox-env fix`` or ``tox -e fix``.
+
 We also collect coverage information from the backend code when you run tests. You can check the
 coverage information provided by the tox output, or by running the following
 command after tox has finished successfully::
index ecc1d86263a6a73a5658a89ccb0a1af6bbfa0783..f4df842a641450f561c167e15647a6ebc2c4b28f 100644 (file)
@@ -1,9 +1,10 @@
-pylint
-flake8
-flake8-colors
+pylint==2.3.1; python_version >= '3'
+flake8==3.7.8; python_version >= '3'
+flake8-colors==0.1.6; python_version >= '3'
 #TODO: Fix docstring issues: https://tracker.ceph.com/issues/41224
 #flake8-docstrings
 #flake8-import-order
 #flake8-typing-imports; python_version >= '3'
 #pep8-naming
-rstcheck
+rstcheck==3.3.1; python_version >= '3'
+autopep8; python_version >= '3'
index 9897a677c03f18fa7882d72fc7da808165237772..6342704c588b5d36e0c4b1b0bbaf3c9fc17a339c 100644 (file)
@@ -2,6 +2,7 @@
 envlist =
     py{27,3},
     lint,
+    fix,
     check,
     run,
 skipsdist = true
@@ -35,7 +36,18 @@ commands = {posargs}
 [flake8]
 max-line-length = 100
 ignore = E123 E126 E226 E402 W503 E741 F812
-exclude = venv, frontend, .*
+exclude =
+    .tox,
+    .git,
+    __pycache__,
+    build,
+    dist,
+    *.egg-info,
+    .cache,
+    *.pyc,
+    .eggs,
+    venv,
+    frontend,
 statistics = True
 #TODO: Uncomment and refactor (https://tracker.ceph.com/issues/41221)
 #max-complexity = 10
@@ -58,13 +70,32 @@ dirs =
     HACKING.rst
 
 [testenv:lint]
-basepython = python3
+basepython=python3
 deps =
     -rrequirements-lint.txt
 commands =
-    rstcheck --report info --debug {posargs:{[rstlint]dirs}}
-    flake8 {posargs}
-    pylint {[pylint]addopts} {posargs:{[pylint]dirs}}
+    lint: flake8 {posargs}
+    lint: pylint {[pylint]addopts} {posargs:{[pylint]dirs}}
+    lint: rstcheck --report info --debug {posargs:{[rstlint]dirs}}
+
+
+[autopep8]
+addopts =
+    --max-line-length {[flake8]max-line-length}
+    --exclude "{[flake8]exclude}"
+    --in-place
+    --recursive
+# TODO: we should progressively increase the level of compliance with PEP8
+#    --aggressive
+#    --aggressive
+
+[testenv:fix]
+basepython=python3
+deps =
+    -rrequirements-lint.txt
+commands =
+    python --version
+    autopep8 {[autopep8]addopts} {posargs:.}
 
 
 [testenv:check]