Skip to content

How to make isort black compatible. Original Question: isort conflicts with black? #1518

@tordbb

Description

@tordbb

Hi.

I experience that black and isort undo eachothers changes when working on some of my files.

I am using the following two first steps in my .pre-commit-config.yaml:

repos:
  - repo: https://github.com/psf/black
    rev: 20.8b1
    hooks:
      - id: black

  - repo: https://github.com/pycqa/isort
    rev: 5.5.4
    hooks:
      - id: isort

When I run pre-commit run --all-files, both black and isort report they are making changes.
The changes result to the following formatting in my file configs.py:

from datetime import date

from cost_categories import (applsj, asjdfsi, bananana, sdjffsd, sjdifjsl,
                             sjdil, yoyoyoyoy)
from library_user import User

However, if I remove the isort-hook from the yaml file, the conflict stops.
Then, I get the following output (as dictated by black alone):

from datetime import date

from cost_categories import (
    applsj,
    asjdfsi,
    bananana,
    sdjffsd,
    sjdifjsl,
    sjdil,
    yoyoyoyoy,
)
from library_user import User

How should I approach this? Am I using some wrong revision?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions