mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00
[ty] Add a subdiagnostic if invalid-return-type
is emitted on a method with an empty body on a non-protocol subclass of a protocol class (#18243)
This commit is contained in:
parent
da4be789ef
commit
41463396cf
6 changed files with 178 additions and 65 deletions
|
@ -546,6 +546,13 @@ impl NodeWithScopeKind {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn as_class(&self) -> Option<&ast::StmtClassDef> {
|
||||
match self {
|
||||
Self::Class(class) => Some(class.node()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_function(&self) -> &ast::StmtFunctionDef {
|
||||
self.as_function().expect("expected function")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue