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

Missing isort configuration to work with black. #897

Closed
picciama opened this issue Mar 7, 2022 · 1 comment · Fixed by #898
Closed

Missing isort configuration to work with black. #897

picciama opened this issue Mar 7, 2022 · 1 comment · Fixed by #898
Labels
bug Something isn't working

Comments

@picciama
Copy link

picciama commented Mar 7, 2022

Associated Template/Command/Core

cookietemple create -> cli -> python

Describe the bug

When running the pre-commit hooks, isort may conflict with black. The problem is that isort sometimes reorders differently than black. This leads to failure of the pre-commit test because the change that is made by black is immediately reversed by isort.
In the end, no file has been changed but the test thinks it failed.
This behaviour can be circumvented by forcing isort to be cautious about changes made by black.
One can add --profile black.
This could either be done in .pre-commit-config.yaml:

repos:
     ...
     - repo: https://github.com/pycqa/isort
       rev: 5.8.0
       hooks:
          - id: isort
            name: isort (python)
            args: ["--profile", "black"]  # new code
     ...

or adding this to pyproject.toml in the default TEMPLATE:

[tool.isort]
profile = "black"

Further information: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html

To Reproduce

Steps to reproduce the behavior:

Not sure how to reproduce it exactly as I cannot remember what caused the conflict in my case.
But this issue provides an example: PyCQA/isort#1518

Expected behavior

Black and isort should both agree and agree at all times when executing the pre-commit hooks.

System [please complete the following information]:

  • OS: Debian 11
  • Python: 3.8 / 3.9
  • Virtual environment: conda
  • cookietemple: 1.3.11

Additional context


@picciama picciama added the bug Something isn't working label Mar 7, 2022
@Zethson
Copy link
Member

Zethson commented Mar 7, 2022

Imipenem added a commit that referenced this issue Mar 8, 2022
Imipenem added a commit that referenced this issue Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants