Skip to content

[isort] force-sort-within-sections and lines-between-types should probably be incompatible #8792

@bluthej

Description

@bluthej

Current behavior

When setting force-sort-within-sections to true and lines-between-types to 1, Ruff adds a blank line before the first from import that appears after a straight import.

(Presumably) desired behavior

isort does not add blank lines in this situation, which I think makes sense, so I propose to stick to that behavior. I guess the force-sort-within-sections setting should simply override the lines-between-types setting.

Example

I tested isort with force_sort_within_sections and lines_between_types = 1 against the following example:

from a import x
import b
from c import y
import d

and it doesn't do anything. Here is the command I ran (isort version 5.12.0):

isort --fss --lbt 1 --stdout example.py

However, running cargo r -p ruff_cli -- check example.py --no-cache --diff adds a blank line after import b with the following config:

select = ["I001"]

[isort]
force-sort-within-sections = true
lines-between-types = 1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingisortRelated to import sorting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions