E274: allow tab indentation before keyword (#9099)

## Summary

E274 currently flags any keyword at the start of a line indented with
tabs. This turns out to be due to a bug in `Whitespace::trailing` that
never considers any whitespace containing a tab as indentation.

## Test Plan

Added a simple test case.
This commit is contained in:
Samuel Cormier-Iijima 2023-12-11 15:25:31 -05:00 committed by GitHub
parent f452bf8cad
commit 1026ece946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -60,3 +60,6 @@ def f():
if (a and if (a and
b): b):
pass pass
#: Okay
def f():
return 1

View file

@ -381,20 +381,16 @@ impl Whitespace {
} }
} }
if has_tabs { if len == content.text_len() {
// All whitespace up to the start of the line -> Indent
(Self::None, TextSize::default())
} else if has_tabs {
(Self::Tab, len) (Self::Tab, len)
} else { } else {
match count { match count {
0 => (Self::None, TextSize::default()), 0 => (Self::None, TextSize::default()),
1 => (Self::Single, len), 1 => (Self::Single, len),
_ => { _ => (Self::Many, len),
if len == content.text_len() {
// All whitespace up to the start of the line -> Indent
(Self::None, TextSize::default())
} else {
(Self::Many, len)
}
}
} }
} }
} }