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)
envlist =
py3
mypy
- fix
flake8
+ check-black
skipsdist = true
[flake8]
-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