Skip to content

Commit

Permalink
Move black configuration in pyproject.toml
Browse files Browse the repository at this point in the history
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 psf/black#861 (comment)
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 <[email protected]>
  • Loading branch information
MVrachev committed Dec 1, 2021
1 parent 8ba3cc4 commit 4597761
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <filename>
$ isort --line-length 80 --profile black -p tuf tuf/api

or via source code editor plugin
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4597761

Please sign in to comment.