Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure black and isort only once in pyproject.toml #1684

Closed
lukpueh opened this issue Nov 18, 2021 · 4 comments · Fixed by #1699
Closed

Configure black and isort only once in pyproject.toml #1684

lukpueh opened this issue Nov 18, 2021 · 4 comments · Fixed by #1699
Assignees
Labels
backlog Issues to address with priority for current development goals
Milestone

Comments

@lukpueh
Copy link
Member

lukpueh commented Nov 18, 2021

Description of issue or feature request:

#1626 added a pyproject.toml, which can be used to configure code formatters black and isort in one place only. Let's put the config parameters (line length, which files to include, etc) there.

See corresponding docs

Current behavior:
Repeated black and isort config in:

Expected behavior:
Single source of truth for black and isort config in pyproject.toml

@MVrachev
Copy link
Collaborator

I am planning to do that when resolving #1582.
I am submitting changes applying each of the linters separately and in the end, will add a pr moving the linters configuration options in pyproject.toml and actually starting linting the tests.

@sechkova sechkova added the backlog Issues to address with priority for current development goals label Nov 24, 2021
@sechkova sechkova added this to the Sprint 13 milestone Nov 24, 2021
@MVrachev
Copy link
Collaborator

MVrachev commented Nov 29, 2021

I was successful in moving all of the black configuration options in pyproject.toml except those about which files are included. These days I tried multiple ways to use the include option, so we can just call black --config=pyproject.toml, but I was not successful.
Finally, I found this comment psf/black#861 (comment), and issue psf/black#740 which explained that we can't use black without the --path argument included.
As a result, I will move all configuration options for black inside pyproject.toml without the actual directories that need to be linted.

@MVrachev
Copy link
Collaborator

MVrachev commented Nov 30, 2021

It's the same situation with isort as it was with black.
I thought I can use only src_path and remove the target directories, but it seems I am wrong because when I tried running isort with isort --settings-path=pyproject.toml I got the error: Error: arguments passed in without any paths or content.
I am not the only one with that problem as a user explicitly asked about that PyCQA/isort#1616 and I saw one project with source configuration https://github.com/Pylons/pyramid/blob/master/pyproject.toml, but they had to give explicit folders too https://github.com/Pylons/pyramid/blob/8061fce297cc7117d3e6e2b39e47512c7db2904f/tox.ini#L26 and https://github.com/Pylons/pyramid/blob/8061fce297cc7117d3e6e2b39e47512c7db2904f/tox.ini#L66

As a result, I will move all configuration options for isort inside pyproject.toml without the actual directories that need to be linted.

@MVrachev
Copy link
Collaborator

MVrachev commented Nov 30, 2021

Sadly, I can't move check and diff attributes as well. In the documentation it's said that for both check and diff are not supported in configuration files.
Additionally, in two issues PyCQA/isort#954 and PyCQA/isort#599 it was confirmed that in integration tests we should use --check and --diff the way we did until now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues to address with priority for current development goals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants