Skip to content

Commit

Permalink
Ignore colon-after-lambda in compound statement rules (#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Feb 11, 2023
1 parent 77099dc commit 43b7ee2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/ruff/resources/test/fixtures/pycodestyle/E70.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ class C: pass
#:
if a := 1:
pass
#:
func = lambda x: x** 2 if cond else lambda x:x
15 changes: 15 additions & 0 deletions crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ pub fn compound_statements(lxr: &[LexResult]) -> Vec<Diagnostic> {
}

match tok {
Tok::Lambda => {
// Reset.
def = None;
colon = None;
class = None;
elif = None;
else_ = None;
except = None;
finally = None;
for_ = None;
if_ = None;
try_ = None;
while_ = None;
with = None;
}
Tok::If => {
if_ = Some((start, end));
}
Expand Down

0 comments on commit 43b7ee2

Please sign in to comment.