astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.04k stars 1.07k forks source link

Feature: Support isort force_grid_wrap config #2601

Open mikelane opened 1 year ago

mikelane commented 1 year ago

The isort library has a setting that will "force number of from imports to be grid wrapped regardless of line length." Using this option will make it so the users can configure how the imports will wrap when using grid mode. This is particularly useful for when it is desirable to have every import on a unique line (which makes it much easier to identify what has changed in a PR, for example).

Ideally this would follow the isort setting:

[tool.ruff.isort]
force_grid_wrap = 2  # Wrap from imports starting at the 2nd import

When coupled with the multi_line_output = 3 mode, for example, imports that start as this:

from itertools import permutations, combinations

become this:

from itertools import (
    combinations,
    permutations,
)
spaceone commented 1 year ago

See also #2600

msto commented 3 weeks ago

Would love to see this implemented!