Skip to content

Commit

Permalink
fix: trigger E301 on decorated methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoel-bagard authored and MichaReiser committed Mar 1, 2024
1 parent 99dcb76 commit fd2c46f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ impl BlankLinesChecker {
if self.is_not_first_logical_line {
if line.preceding_blank_lines == 0
// Only applies to methods.
&& matches!(line.kind, LogicalLineKind::Function)
&& matches!(self.class_status, Status::Inside(_))
&& matches!(line.kind, LogicalLineKind::Function | LogicalLineKind::Decorator)
// Allow groups of one-liners.
&& !(matches!(state.follows, Follows::Def) && !matches!(line.last_token, TokenKind::Colon))
&& matches!(state.class_status, Status::Inside(_))
// The class/parent method's docstring can directly precede the def.
// Allow following a decorator (if there is an error it will be triggered on the first decorator).
&& !matches!(self.follows, Follows::Docstring | Follows::Decorator)
Expand Down

0 comments on commit fd2c46f

Please sign in to comment.