mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 17:32:25 +00:00
Include method name in B027 message (#2403)
This commit is contained in:
parent
c3a3195922
commit
293c7e00d5
2 changed files with 14 additions and 11 deletions
|
@ -62,16 +62,19 @@ pub fn abstract_base_class(
|
|||
continue;
|
||||
}
|
||||
|
||||
let (StmtKind::FunctionDef {
|
||||
let (
|
||||
StmtKind::FunctionDef {
|
||||
decorator_list,
|
||||
body,
|
||||
name: method_name,
|
||||
..
|
||||
} | StmtKind::AsyncFunctionDef {
|
||||
decorator_list,
|
||||
body,
|
||||
name: method_name,
|
||||
..
|
||||
}
|
||||
| StmtKind::AsyncFunctionDef {
|
||||
decorator_list,
|
||||
body,
|
||||
..
|
||||
}) = &stmt.node else {
|
||||
) = &stmt.node else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -89,7 +92,7 @@ pub fn abstract_base_class(
|
|||
if !has_abstract_decorator && is_empty_body(body) && !is_overload(checker, decorator_list) {
|
||||
checker.diagnostics.push(Diagnostic::new(
|
||||
violations::EmptyMethodWithoutAbstractDecorator {
|
||||
name: name.to_string(),
|
||||
name: format!("{name}.{method_name}"),
|
||||
},
|
||||
Range::from_located(stmt),
|
||||
));
|
||||
|
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
|||
---
|
||||
- kind:
|
||||
EmptyMethodWithoutAbstractDecorator:
|
||||
name: AbstractClass
|
||||
name: AbstractClass.empty_1
|
||||
location:
|
||||
row: 13
|
||||
column: 4
|
||||
|
@ -15,7 +15,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
EmptyMethodWithoutAbstractDecorator:
|
||||
name: AbstractClass
|
||||
name: AbstractClass.empty_2
|
||||
location:
|
||||
row: 16
|
||||
column: 4
|
||||
|
@ -26,7 +26,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
EmptyMethodWithoutAbstractDecorator:
|
||||
name: AbstractClass
|
||||
name: AbstractClass.empty_3
|
||||
location:
|
||||
row: 19
|
||||
column: 4
|
||||
|
@ -37,7 +37,7 @@ expression: diagnostics
|
|||
parent: ~
|
||||
- kind:
|
||||
EmptyMethodWithoutAbstractDecorator:
|
||||
name: AbstractClass
|
||||
name: AbstractClass.empty_4
|
||||
location:
|
||||
row: 23
|
||||
column: 4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue