Include method name in B027 message (#2403)

This commit is contained in:
Charlie Marsh
2023-01-31 12:41:22 -05:00
committed by GitHub
parent c3a3195922
commit 293c7e00d5
2 changed files with 14 additions and 11 deletions

View File

@@ -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),
));

View File

@@ -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