PyCQA / PyCQA/isort

`--force-alphabetical-sort` breaks `--lines-between-types=0`

Open
#1,972 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

Hello, and thanks for a very useful package!

If I set --force-alphabetical-sort then an extra line is inserted between import and from even if --lines-between-types=0

Start with this test file:

import one
import two
from three import four
from five import six

HELLO = 'world'

Running isort --lines-between-types=0 test_isort.py gets:

import one
import two
from five import six
from three import four

HELLO = 'world'

This has no empty line between import and from as expected.

isort --force-alphabetical-sort --lines-between-types=0 test_isort.py gives:

from five import six
from three import four

import one
import two

HELLO = 'world'

which you will note adds an empty line!


Thanks and have an excellent weekend.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the commands and reproducer in test_isort.py, comparing output with and without --force-alphabetical-sort while --lines-between-types=0 is set. Trace the formatting path responsible for grouping imports, then add or update a regression test so forced alphabetical sorting does not insert an empty line between import and from groups.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.