From 4597761adbc38b711eac159d57ed7f58cbbb72d8 Mon Sep 17 00:00:00 2001 From: Martin Vrachev Date: Sun, 28 Nov 2021 00:16:04 +0200 Subject: [PATCH] Move black configuration in pyproject.toml We are using 4 linters: black, isort, pylint and mypy. It's good if we use one file as a source for truth for all linter configurations. As a first step move black options in pyproject.toml. I tried multiple ways to use the include option, so we can just call black --config=pyproject.toml, but I was not successful. Then I found this comment https://github.com/psf/black/issues/861#issuecomment-680411125 explaining that the path argument is mandatory. As a result, I will move all configuration options for black inside pyproject.toml without the actual directories that need to be linted. Signed-off-by: Martin Vrachev --- docs/CONTRIBUTORS.rst | 2 +- pyproject.toml | 6 ++++++ tox.ini | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTORS.rst b/docs/CONTRIBUTORS.rst index 302c8c205b..bf68594158 100644 --- a/docs/CONTRIBUTORS.rst +++ b/docs/CONTRIBUTORS.rst @@ -114,7 +114,7 @@ Auto-formatting can be done on the command line: :: $ # TODO: configure black and isort args in pyproject.toml (see #1161) - $ black --line-length 80 tuf/api + $ black $ isort --line-length 80 --profile black -p tuf tuf/api or via source code editor plugin diff --git a/pyproject.toml b/pyproject.toml index 245e2cdf5f..be5e723804 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,13 @@ +# Build-system section [build-system] requires = ["setuptools>=40.8.0", "wheel"] build-backend = "setuptools.build_meta" +# Black section +# Read more here: https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file +[tool.black] +line-length=80 + # Pylint section # Minimal pylint configuration file for Secure Systems Lab Python Style Guide: diff --git a/tox.ini b/tox.ini index 767b1b4a86..b06150ea57 100644 --- a/tox.ini +++ b/tox.ini @@ -41,7 +41,7 @@ changedir = {toxinidir} commands = # Use different configs for new (tuf/api/*) and legacy code # TODO: configure black and isort args in pyproject.toml (see #1161) - black --check --diff --line-length 80 tuf/api tuf/ngclient + black --check --diff tuf/api tuf/ngclient isort --check --diff --line-length 80 --profile black -p tuf tuf/api tuf/ngclient pylint -j 0 tuf/api tuf/ngclient --rcfile=pyproject.toml