Skip to content

Commit

Permalink
Fix decorator + async false positive.
Browse files Browse the repository at this point in the history
This also move the trigger on an async def from the def to the async.
  • Loading branch information
hoel-bagard committed Nov 18, 2023
1 parent b667c5c commit 14b784c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ def function():
# end


# no error
@decorator
async def function(data: None) -> None:
...
# end


# E301
class Class(object):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub(crate) fn blank_lines(
locator.line_start(token.range.start()),
)));
context.push_diagnostic(diagnostic);
} else if matches!(token.kind(), TokenKind::Def | TokenKind::Class | TokenKind::At)
} else if matches!(token.kind(), TokenKind::Def | TokenKind::Class | TokenKind::At | TokenKind::Async)
&& !(
// Allow decorators.
tracked_vars.follows_decorator
Expand Down Expand Up @@ -579,7 +579,7 @@ pub(crate) fn blank_lines(
tracked_vars.follows_def = false;
break;
}
TokenKind::Def => {
TokenKind::Def | TokenKind::Async => {
if !tracked_vars.is_in_fn {
tracked_vars.fn_indent_level = indent_level + indent_size;
}
Expand All @@ -588,10 +588,6 @@ pub(crate) fn blank_lines(
tracked_vars.follows_decorator = false;
break;
}
TokenKind::Async => {
tracked_vars.follows_decorator = false;
tracked_vars.follows_def = false;
}
TokenKind::Comment => {
break;
}
Expand Down

0 comments on commit 14b784c

Please sign in to comment.