mirror of https://github.com/astral-sh/ruff
Include method name in B027 message (#2403)
This commit is contained in:
parent
c3a3195922
commit
293c7e00d5
|
|
@ -62,16 +62,19 @@ pub fn abstract_base_class(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (StmtKind::FunctionDef {
|
let (
|
||||||
|
StmtKind::FunctionDef {
|
||||||
decorator_list,
|
decorator_list,
|
||||||
body,
|
body,
|
||||||
|
name: method_name,
|
||||||
|
..
|
||||||
|
} | StmtKind::AsyncFunctionDef {
|
||||||
|
decorator_list,
|
||||||
|
body,
|
||||||
|
name: method_name,
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
| StmtKind::AsyncFunctionDef {
|
) = &stmt.node else {
|
||||||
decorator_list,
|
|
||||||
body,
|
|
||||||
..
|
|
||||||
}) = &stmt.node else {
|
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -89,7 +92,7 @@ pub fn abstract_base_class(
|
||||||
if !has_abstract_decorator && is_empty_body(body) && !is_overload(checker, decorator_list) {
|
if !has_abstract_decorator && is_empty_body(body) && !is_overload(checker, decorator_list) {
|
||||||
checker.diagnostics.push(Diagnostic::new(
|
checker.diagnostics.push(Diagnostic::new(
|
||||||
violations::EmptyMethodWithoutAbstractDecorator {
|
violations::EmptyMethodWithoutAbstractDecorator {
|
||||||
name: name.to_string(),
|
name: format!("{name}.{method_name}"),
|
||||||
},
|
},
|
||||||
Range::from_located(stmt),
|
Range::from_located(stmt),
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
EmptyMethodWithoutAbstractDecorator:
|
EmptyMethodWithoutAbstractDecorator:
|
||||||
name: AbstractClass
|
name: AbstractClass.empty_1
|
||||||
location:
|
location:
|
||||||
row: 13
|
row: 13
|
||||||
column: 4
|
column: 4
|
||||||
|
|
@ -15,7 +15,7 @@ expression: diagnostics
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
EmptyMethodWithoutAbstractDecorator:
|
EmptyMethodWithoutAbstractDecorator:
|
||||||
name: AbstractClass
|
name: AbstractClass.empty_2
|
||||||
location:
|
location:
|
||||||
row: 16
|
row: 16
|
||||||
column: 4
|
column: 4
|
||||||
|
|
@ -26,7 +26,7 @@ expression: diagnostics
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
EmptyMethodWithoutAbstractDecorator:
|
EmptyMethodWithoutAbstractDecorator:
|
||||||
name: AbstractClass
|
name: AbstractClass.empty_3
|
||||||
location:
|
location:
|
||||||
row: 19
|
row: 19
|
||||||
column: 4
|
column: 4
|
||||||
|
|
@ -37,7 +37,7 @@ expression: diagnostics
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
EmptyMethodWithoutAbstractDecorator:
|
EmptyMethodWithoutAbstractDecorator:
|
||||||
name: AbstractClass
|
name: AbstractClass.empty_4
|
||||||
location:
|
location:
|
||||||
row: 23
|
row: 23
|
||||||
column: 4
|
column: 4
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue