Skip to content

Interopability with black #694

@ambv

Description

@ambv

Hey, Timothy! Thanks for isort, it's a very useful project.

I made an opinionated formatter, Black. Quite a few of my users are also isort users. That's great, I don't want to have to perform import sorting in Black. However, there's a small issue.

None of isort's multiline modes fits what Black is doing. Black wraps lines like this:

  • try to fit everything in one line; if you can't then
  • indent the contents of the parens one level and try to fit those in one line; if you can't then
  • explode one element per line.

The second step in Black's algorithm is like your mode 5, and the third is like mode 3. I'd like to create a pull request for isort to introduce mode 8 (5+3) that does what Black does in this scenario. This would enable Black and isort to co-exist and keep consistent import styling.

Would you accept such pull request?

(I initially wrote this on Twitter but this belongs here better.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    blackBlack compatibility issueenhancementNew feature or requestongoingA task that represents continous work and coordination and is never meant to be "complete"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions