Skip to content

fix: preserve configured lines_between_types with force_alphabetical_sort (#1972) - #2797

Open
Yshuro wants to merge 2 commits into
PyCQA:mainfrom
Yshuro:fix/force-alphabetical-sort-lines-between-types
Open

Yshuro wants to merge 2 commits into
PyCQA:mainfrom
Yshuro:fix/force-alphabetical-sort-lines-between-types

Conversation

@Yshuro

@Yshuro Yshuro commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1972 where configuring --force-alphabetical-sort unconditionally forced lines_between_types = 1, overriding any user configuration setting lines_between_types = 0 (or other values) via config files or CLI flags.

Changes

  • isort/settings.py: In _Config.__post_init__, only set lines_between_types = 1 as a default when lines_between_types was not explicitly provided in any non-default configuration source (self.sources[1:]).
  • isort/main.py: Update parse_args dictionary comprehension so integer CLI arguments equal to 0 (such as --lines-between-types 0 / --lbt 0) are not dropped by the truthiness check.
  • Tests:
    • Added unit test in tests/unit/test_isort.py verifying default force_alphabetical_sort behavior, lines_between_types=0, and custom values.
    • Added CLI tests in tests/unit/test_main.py verifying --lines-between-types 0 and --lbt 0 parsing.

Closes #1972

…sort (PyCQA#1972)

Signed-off-by: Yshuro <yshuro1080@gmail.com>
@Yshuro
Yshuro force-pushed the fix/force-alphabetical-sort-lines-between-types branch from ee8905b to 41f5bfb Compare November 19, 2026 18:35
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.39%. Comparing base (f5b5649) to head (41f5bfb).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2797   +/-   ##
=======================================
  Coverage   99.39%   99.39%           
=======================================
  Files          40       40           
  Lines        3317     3318    +1     
  Branches      716      717    +1     
=======================================
+ Hits         3297     3298    +1     
  Misses         12       12           
  Partials        8        8           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Yshuro <yshuro1080@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant