autopep8 icon indicating copy to clipboard operation
autopep8 copied to clipboard

Doesn't seem to support tabs properly.

Open sdfgeoff opened this issue 6 years ago • 5 comments

I am modifying autopep8 and pycodestyle to work with another programming language that is very similar to python. However, the style guide for this other language is that it should use tabs.

I modified pycodestyle to use tabs by modifying "indent_char" to a '\t'.

In autopep8, I saw the lines:

 if indent_char != '\t' else (DEFAULT_INDENT_SIZE,
                                     2 * DEFAULT_INDENT_SIZE)
    )

And thought this meant it would read the indent character from pycodestyle.

However, upon execution, it always completely overwrites the tabs with spaces. This issue https://github.com/jorgenschaefer/elpy/issues/680 seems to suggest it should work. A similar issue is already reported here https://github.com/hhatto/autopep8/issues/207 where they suggest using --ignore=E101,E111 but this disables all reindentation (ie an incorrectly indented line is not fixed).

I struggle to find the part of the code that actually does the reindentation. I would have expected it to be the "Reindenter" class, but it seems that by the time the lines are passed in there, they're already space-ified.

I'm aware this is outside the normal use-case of autopep8, but was wondering if one of the devs could give me some guidance on how to make it support the indentation with tabs rather than spaces.

sdfgeoff avatar Jan 24 '19 14:01 sdfgeoff

Same problem here. I prefer tabs as indents.

birgersp avatar Nov 28 '19 08:11 birgersp

Nothing on this still?

alexreg avatar Feb 16 '21 03:02 alexreg

I too have to follow a coding style that uses tabs instead of spaces

MajorBarnulf avatar Oct 21 '21 17:10 MajorBarnulf

still waiting on this

ccrsxx avatar Nov 18 '21 01:11 ccrsxx

it works with an old version: autopep8 0.9.1 (at least when ignoring E501,E101,W191,E126,E128) pip install autopep8==0.9.1

See also https://github.com/hhatto/autopep8/issues/242 https://github.com/hhatto/autopep8/issues/417

spaceone avatar Jan 12 '23 16:01 spaceone