mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:09 +00:00
Supported starred exceptions in length-one tuple detection (#7080)
This commit is contained in:
parent
b70dde4a77
commit
b0d171ac19
4 changed files with 49 additions and 17 deletions
|
@ -653,6 +653,17 @@ pub fn map_subscript(expr: &Expr) -> &Expr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Given an [`Expr`] that can be starred, return the underlying starred expression.
|
||||
pub fn map_starred(expr: &Expr) -> &Expr {
|
||||
if let Expr::Starred(ast::ExprStarred { value, .. }) = expr {
|
||||
// Ex) `*args`
|
||||
value
|
||||
} else {
|
||||
// Ex) `args`
|
||||
expr
|
||||
}
|
||||
}
|
||||
|
||||
/// Return `true` if the body uses `locals()`, `globals()`, `vars()`, `eval()`.
|
||||
///
|
||||
/// Accepts a closure that determines whether a given name (e.g., `"list"`) is a Python builtin.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue