mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
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:
parent
f452bf8cad
commit
1026ece946
2 changed files with 8 additions and 9 deletions
|
@ -60,3 +60,6 @@ def f():
|
|||
if (a and
|
||||
b):
|
||||
pass
|
||||
#: Okay
|
||||
def f():
|
||||
return 1
|
||||
|
|
|
@ -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)
|
||||
} else {
|
||||
match count {
|
||||
0 => (Self::None, TextSize::default()),
|
||||
1 => (Self::Single, len),
|
||||
_ => {
|
||||
if len == content.text_len() {
|
||||
// All whitespace up to the start of the line -> Indent
|
||||
(Self::None, TextSize::default())
|
||||
} else {
|
||||
(Self::Many, len)
|
||||
}
|
||||
}
|
||||
_ => (Self::Many, len),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue