yapf: use_tabs=True does not work for lists and dictionaries
We use_tabs for indentation but continuation_indent_width still uses spaces instead of tabs for lists and dictionaries that are split over multiple lines. If required there should be a separate knob for this which allows setting of tabs vs spaces for lists and dictionaries
``
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 33 (13 by maintainers)
@gwelymernans, there are 2 basic school of thoughts (amongst us tabbers=tab users) for continuation alignment
Currently yapf does a very unexpected switchover back to pure spaces for continuation indentation which is probably completely invalid for any tabber.
If yapf has to truly cater to tab users, it will probably have to have a flag for those of us in the 2nd school of mixed indentation
hope I have helped
Thanks for not starting a ‘holy war’ on this 👍 . Ideally, though this may vary even amongst us ‘tabs’ people, I think I would want the continuation indent to be additional to the indent at which the code is at right now. so CONTINUATION_INDENT=1 should result in the code below Eg below
SPACE and FIXED are reasonable options. LESS and MORE just don’t make sense to me. When would that ever be useful? The major point of using tabs is that their width can be customized in the editor.
@ichibrosan, I think you mean conform or die, I say NEVER 😃
Greg literally wrote this in the last message (VS code).
On the topic of this issue, I think it is strange that E101 reports spaces used for vertical alignment. Vertical alignment is used in PEP8 and there is no reasonable way of aligning things vertically like that without tabs. There is really two types of indentation in programming: scope indentation and indentation used for line continuation.
Other style guides (not PEP8) require not using vertical alignment, because this can a single line change to have a “blast radius” to other lines. Having a setting to use only a single tab for line continuation is not unreasonable.
Personally, I am happy with the current functionality.
On Fri, Feb 9, 2018 at 1:07 PM Anshuman Aggarwal notifications@github.com wrote:
Yes,
E101also apply to continuation indentations. There isn’t space mixed within tabs like\t \tin my example as you can see all invisible chars in the screenshots. (I’m using Visual Studio Code.) One tab per indentation level is the way to go.For your example, we can format like this.
Or like this, without enclosing bracket.
But not with space 😦
The behavior of current implementation in
masteris also weird for condition without enclosing bracket:I agree with @eskhool: an opening character (brace, bracket, etc.) give me an extra indent (ie. tab) on the next line. As a “tabber” too, I can not understand the trend to do ASCII-art and space based alignment 😃, where you break everything each time you change a name…
Nonetheless, thank you for yapf