]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use check-black environment, drop fix
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 9 Mar 2024 16:37:49 +0000 (11:37 -0500)
committerAdam King <adking@redhat.com>
Tue, 19 Mar 2024 17:47:58 +0000 (13:47 -0400)
A few months ago when we were starting the cephadm refactoring effort in
earnest we agreed to use `black` to format the python files we moved
into `cephadmlib` (while leaving the formatting of cephadm.py as-is).
We created tox rules to check or apply black formatting but promptly
got lazy and stopped running the checks manually - they were not run
automatically.

Change the default environment list to call check-black to start
enforcing the use of black style formatting. At the same time, remove
the `fix` environment entirely. It is liable to leave uncommitted changes
in your working tree when run - unlike check-black. This moves cephadm
practices closer to ones I've seen widely used in other python
codebases.

Note that cephadm.py remains outside of this rule - it only requires
pep8 formatting (via flake8). cephadm.py should continue to be
disassembled and components moved into cephadmlib over time. flake8 also remains
in effect for cephadmlib, it's fast, finds obvious mistakes and does
some code-level linting (like unused vars) that black does not.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 155a91bfb0b6fdf9563a907b2aa5740e00046e6e)

src/cephadm/tox.ini

index 4871c186b3e383d6484550fd118e99d43ec1ce88..8c3728ff4c9b0417de25aa90fc04d1f3a40e054b 100644 (file)
@@ -2,8 +2,8 @@
 envlist =
     py3
     mypy
-    fix
     flake8
+    check-black
 skipsdist = true
 
 [flake8]
@@ -50,14 +50,6 @@ deps =
     -c{toxinidir}/../mypy-constrains.txt
 commands = mypy --config-file ../mypy.ini {posargs:cephadm.py cephadmlib}
 
-[testenv:fix]
-basepython = python3
-deps =
-    autopep8
-commands =
-    python --version
-    autopep8 {[autopep8]addopts} {posargs: cephadm.py}
-
 [testenv:flake8]
 basepython = python3
 allowlist_externals = bash