Move part of isort options 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.

I tried multiple ways to use the src_path option,
so we can just call isort without pointing out the target folders, but I was not
successful.
I tried running isort with "isort --settings-path=pyproject.toml"
I got the error:
"Error: arguments passed in without any paths or content."

Additionally, I saw one project with source configuration https://github.com/Pylons/pyramid/blob/master/pyproject.toml,
but they had to give explicit folders too 8061fce297/tox.ini (L26)
and 8061fce297/tox.ini (L66)

It was a similar situation with "check" and "diff".
In the documentation it's said that for both check and diff are not
supported in configuration files.
See:
- https://pycqa.github.io/isort/docs/configuration/options.html#check
- https://pycqa.github.io/isort/docs/configuration/options.html#show-diff

Additionally, in two issues it was confirmed that in integration tests
we should use --check and --diff the way we did until now.

As a result, I moved part of the configuration options for isort inside
pyproject.toml without the actual directories that need to be linted
and "check" and "diff" options.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
Martin Vrachev 2021-11-30 16:40:44 +02:00
parent 4597761adb
commit ed8a06bcb3
3 changed files with 9 additions and 4 deletions

View file

@ -113,9 +113,8 @@ CI/CD will check that new TUF code is formatted with `black
Auto-formatting can be done on the command line:
::
$ # TODO: configure black and isort args in pyproject.toml (see #1161)
$ black <filename>
$ isort --line-length 80 --profile black -p tuf tuf/api
$ isort <filename>
or via source code editor plugin
[`black <https://black.readthedocs.io/en/stable/editor_integration.html>`__,

View file

@ -8,6 +8,13 @@ build-backend = "setuptools.build_meta"
[tool.black]
line-length=80
# Isort section
# Read more here: https://pycqa.github.io/isort/docs/configuration/config_files.html
[tool.isort]
profile="black"
line_length=80
known_first_party = ["tuf"]
# Pylint section
# Minimal pylint configuration file for Secure Systems Lab Python Style Guide:

View file

@ -40,9 +40,8 @@ commands =
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 tuf/api tuf/ngclient
isort --check --diff --line-length 80 --profile black -p tuf tuf/api tuf/ngclient
isort --check --diff tuf/api tuf/ngclient
pylint -j 0 tuf/api tuf/ngclient --rcfile=pyproject.toml
# NOTE: Contrary to what the pylint docs suggest, ignoring full paths does