mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-29 23:04:32 +00:00
Refactor the ExprDict
node (#11267)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
de270154a1
commit
6774f27f4b
52 changed files with 2425 additions and 2240 deletions
|
@ -155,14 +155,12 @@ pub fn any_over_expr(expr: &Expr, func: &dyn Fn(&Expr) -> bool) -> bool {
|
|||
orelse,
|
||||
range: _,
|
||||
}) => any_over_expr(test, func) || any_over_expr(body, func) || any_over_expr(orelse, func),
|
||||
Expr::Dict(ast::ExprDict {
|
||||
keys,
|
||||
values,
|
||||
range: _,
|
||||
}) => values
|
||||
.iter()
|
||||
.chain(keys.iter().flatten())
|
||||
.any(|expr| any_over_expr(expr, func)),
|
||||
Expr::Dict(ast::ExprDict { items, range: _ }) => {
|
||||
items.iter().any(|ast::DictItem { key, value }| {
|
||||
any_over_expr(value, func)
|
||||
|| key.as_ref().is_some_and(|key| any_over_expr(key, func))
|
||||
})
|
||||
}
|
||||
Expr::Set(ast::ExprSet { elts, range: _ })
|
||||
| Expr::List(ast::ExprList { elts, range: _, .. })
|
||||
| Expr::Tuple(ast::ExprTuple { elts, range: _, .. }) => {
|
||||
|
@ -1188,8 +1186,8 @@ impl Truthiness {
|
|||
Self::Truthy
|
||||
}
|
||||
}
|
||||
Expr::Dict(ast::ExprDict { keys, .. }) => {
|
||||
if keys.is_empty() {
|
||||
Expr::Dict(ast::ExprDict { items, .. }) => {
|
||||
if items.is_empty() {
|
||||
Self::Falsey
|
||||
} else {
|
||||
Self::Truthy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue