Skip to content

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

Closed

Description

@lukpueh

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

Activity

  1. MVrachev commented on Nov 18, 2021

    @MVrachev
    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.

  2. added
    backlog
    on Nov 24, 2021
  3. added this to the Sprint 13 milestone on Nov 24, 2021
  4. MVrachev commented on Nov 29, 2021

    @MVrachev
    Collaborator

    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.

  5. MVrachev commented on Nov 30, 2021

    @MVrachev
    Collaborator

    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.

  6. MVrachev commented on Nov 30, 2021

    @MVrachev
    Collaborator

    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

Metadata

Metadata

Assignees

Labels

backlog

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions