mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
Avoid PLE0237
for property with setter (#11377)
## Summary Should this consider the decorator only if the name is actually a property or is the logic in this PR correct? fixes: #11358 ## Test Plan Add test case.
This commit is contained in:
parent
d835b3e218
commit
0fc6cf9bee
2 changed files with 38 additions and 0 deletions
|
@ -147,6 +147,28 @@ fn is_attributes_not_in_slots(body: &[Stmt]) -> Vec<AttributeAssignment> {
|
|||
return vec![];
|
||||
}
|
||||
|
||||
// And, collect all the property name with setter.
|
||||
for statement in body {
|
||||
let Stmt::FunctionDef(ast::StmtFunctionDef { decorator_list, .. }) = statement else {
|
||||
continue;
|
||||
};
|
||||
|
||||
for decorator in decorator_list {
|
||||
let Some(ast::ExprAttribute { value, attr, .. }) =
|
||||
decorator.expression.as_attribute_expr()
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if attr == "setter" {
|
||||
let Some(ast::ExprName { id, .. }) = value.as_name_expr() else {
|
||||
continue;
|
||||
};
|
||||
slots.insert(id.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Second, find any assignments that aren't included in `__slots__`.
|
||||
let mut assignments = vec![];
|
||||
for statement in body {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue