mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
Implement iter()
, len()
and is_empty()
for all display-literal AST nodes (#12807)
This commit is contained in:
parent
a99a45868c
commit
aa0db338d9
56 changed files with 304 additions and 240 deletions
|
@ -1432,9 +1432,7 @@ impl<'a> SemanticModel<'a> {
|
|||
/// variable to be "used" if it's shadowed by another variable with usages.
|
||||
pub fn is_unused(&self, expr: &Expr) -> bool {
|
||||
match expr {
|
||||
Expr::Tuple(ast::ExprTuple { elts, .. }) => {
|
||||
elts.iter().all(|expr| self.is_unused(expr))
|
||||
}
|
||||
Expr::Tuple(tuple) => tuple.iter().all(|expr| self.is_unused(expr)),
|
||||
Expr::Name(ast::ExprName { id, .. }) => {
|
||||
// Treat a variable as used if it has any usages, _or_ it's shadowed by another variable
|
||||
// with usages.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue