Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
method definitions inside a class are surrounded by a single blank line as
prescribed by PEP8.
- Fixed the '...' token to be spaced after a colon.
- With `USE_TABS=True` and `continuation_align_style=SPACE` no space tab mix
is produced anymore.

## [0.31.0] 2021-03-14
### Added
Expand Down
4 changes: 3 additions & 1 deletion yapf/yapflib/format_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def _TabbedContinuationAlignPadding(spaces, align_style, tab_width):
if spaces > 0:
return '\t' * int((spaces + tab_width - 1) / tab_width)
return ''
return ' ' * spaces
if tab_width > 1 and spaces % tab_width == 0:
return '\t' * (spaces // tab_width)
return ' ' * spaces # TODO: add a comment why we indent with spaces in a tab area?


class FormatToken(object):
Expand Down
2 changes: 1 addition & 1 deletion yapftests/format_token_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def testSpace(self):
self.assertEqual(pad, '')

pad = format_token._TabbedContinuationAlignPadding(2, align_style, 2)
self.assertEqual(pad, ' ' * 2)
self.assertEqual(pad, '\t')

pad = format_token._TabbedContinuationAlignPadding(5, align_style, 2)
self.assertEqual(pad, ' ' * 5)
Expand Down