Repository navigation
Conversation
A config file value of `indent=\t` was used literally, so wrapped imports were written with a backslash followed by `t`, producing a SyntaxError. Also document the accepted values for `indent` and that it only applies to the hanging indent wrap modes. Refs PyCQA#2693
DanielNoord
left a comment
There was a problem hiding this comment.
Are we sure the difference between multi line modes is not a bug? Can we use indent there? Or would that not make a lot of sense?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2708 +/- ##
=======================================
Coverage 99.41% 99.41%
=======================================
Files 41 41
Lines 3229 3230 +1
Branches 689 689
=======================================
+ Hits 3210 3211 +1
Misses 12 12
Partials 7 7 🚀 New features to boost your workflow:
|
|
That's a good question. I would say it was done intentionally and not because of a bug. Grid, Vertical and Backslash Grid align the continuation lines with the column after
And tabs could not produce column alignment, since tab width depends on the editor. So I would keep the current behaviour and use the note in the docs to let people discover it. If you want it to be more obvious, one idea is to show a warning when |
Refs #2693
indent=\tin a config file was used literally, so wrapped imports were written as\tname,(a backslash followed byt), which is aSyntaxErrorin the output:This makes
\tin theindentvalue mean a tab, alongside the existingtab/ number / literal-string handling. It also updates the--indenthelp text anddocs/configuration/options.mdto list the accepted values and to note thatindentonly applies to the hanging-indentmulti_line_outputmodes, because GRID, VERTICAL and BACKSLASH_GRID align with the opening bracket. That explains the original report in #2693.This is separate from #2704: on
main, the quoted and capitalisedtabspellings already work (details in my comment there). This PR only covers the\tcase. I've left out the "reject an emptyindent" idea from my issue comment, since it changes behaviour and is a maintainer call. I can add it here if you'd like.Tests: parametrized
Config(indent=...)cases plus one readingindent=\tfrom a real.isort.cfg. The unit suite passes locally (678 passed), and ruff and mypy are clean.I used Claude to help investigate and write this change; I've reviewed and verified it.