PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

isort 5.12 might be out of sync with black 23.3 (released march 28) #2116

Open lwasser opened 1 year ago

lwasser commented 1 year ago

Hello there! 👋 i just wanted to open this issue as i ran into some problems with black and isort

Previously we were running black and isort (using profile=black) and all was good.

However when updated to black 23.3 we ran into the issue of isort and black endlessing updating files and conflicting with each other. I suspect it's because isort was released in jan and black was just released a few days ago. The fix for me was to bump black back to 23.1. I just wanted to report this in case others were experiencing the same thing.

This is a yaml file that works

https://github.com/stravalib/stravalib/blob/ee381add1d4fa0265869ae881dc81f8d02f5ec96/.pre-commit-config.yaml

but if you try to bump black to the current version it breaks the build again with endless black/isort fixing of a file.

markbarna commented 1 year ago

I ran into this issue as well. My solution was to manually set the isort config to include the specific args needed to make black happy. It looks like this:

- repo: https://github.com/PyCQA/isort
  rev: 5.12.0
  hooks:
  - id: isort
    args: [
      --multi-line, "3",
      --trailing-comma,
      --force-grid-wrap,
      --use-parentheses,
      --ensure-newline-before-comments,
      --line-length, "88",
      --split-on-trailing-comma
    ]