Skip to content

Fix indent=tab normalization for quoted and capitalized .isort.cfg values - #2704

Closed
pradip-pawar1 wants to merge 5 commits into
PyCQA:mainfrom
pradip-pawar1:fix/isort-cfg-indent-normalization
Closed

pradip-pawar1 wants to merge 5 commits into
PyCQA:mainfrom
pradip-pawar1:fix/isort-cfg-indent-normalization

Conversation

@pradip-pawar1

Copy link
Copy Markdown

Fixes #2693

.isort.cfg values like indent="tab" (quoted) or indent=Tab (capitalized) were silently falling back to spaces instead of producing a real tab, because the auto-discovery config path (via find_all_configs/Trie) never ran the existing quote-stripping/tab- normalization logic — that logic only applied when an explicit --settings-path was given.

This moves the normalization into _get_config_data() itself, the function both paths share, so auto-discovered and explicitly-pathed configs behave consistently.

Known remaining limitation: a literal tab byte or escaped \t/\\t in the config value are not normalized — configparser strips whitespace-only values before this code runs, and escape sequences aren't something this fix attempts to interpret. Users should write the word tab or Tab.

@shan3520

shan3520 commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for picking this up! A few things I noticed while testing this against main:

  • I couldn't reproduce the premise that auto-discovered configs skip normalization. On unmodified main, indent=tab, indent=Tab and indent="tab" in .isort.cfg all produce a real tab, both with default config discovery and with --resolve-all-configs. The existing normalization in Config.__init__ runs for both paths, so the new branch in _get_config_data() doesn't change the outcome for these values.
  • Related to that, test_indent_tab_config_normalization passes on main without this change, since it builds Config(indent=...) directly and that already handles "tab" / Tab.
  • The one case that is actually broken is indent=\t, which is used literally and makes isort write invalid Python (see my comment on indent=Tab setting not respected #2693). I have a small fix with tests for that on a branch (shan3520/isort@issue/2693) and I'm happy to fold it in however the maintainers prefer.
  • The .gitignore change (myUse/) looks like it was included by accident.

(Testing done with help from Claude; results verified locally.)

@pradip-pawar1

pradip-pawar1 commented Oct 4, 2026 •

Copy link
Copy Markdown
Author

Thank you for digging into this and testing against clean main — you're right, I can't reproduce the normalization gap either now that I've rechecked. My original reproduction must have been run against a contaminated environment; I missed that config_overrides merges into combined_config unconditionally, so the existing logic already covers both paths. Appreciate you catching this before it went further.

You're also right about the .gitignore change — that was accidental, not meant for this PR.

Given #2708 already has a real fix with tests for the actual indent=\t bug, I'll close this PR rather than duplicate effort. Thanks again for the careful review.

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.

indent=Tab setting not respected

2 participants