mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-27 05:44:18 +00:00
[flake8-pyi
] Implement PYI064
(#11325)
## Summary Implements `Y064` from `flake8-pyi` and its autofix. ## Test Plan `cargo test` / `cargo insta review`
This commit is contained in:
parent
9a3b9f9fb5
commit
e0169d8dea
11 changed files with 389 additions and 5 deletions
|
@ -657,15 +657,14 @@ pub fn map_callable(decorator: &Expr) -> &Expr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Given an [`Expr`] that can be callable or not (like a decorator, which could
|
||||
/// be used with or without explicit call syntax), return the underlying
|
||||
/// callable.
|
||||
/// Given an [`Expr`] that can be a [`ExprSubscript`][ast::ExprSubscript] or not
|
||||
/// (like an annotation that may be generic or not), return the underlying expr.
|
||||
pub fn map_subscript(expr: &Expr) -> &Expr {
|
||||
if let Expr::Subscript(ast::ExprSubscript { value, .. }) = expr {
|
||||
// Ex) `Iterable[T]`
|
||||
// Ex) `Iterable[T]` => return `Iterable`
|
||||
value
|
||||
} else {
|
||||
// Ex) `Iterable`
|
||||
// Ex) `Iterable` => return `Iterable`
|
||||
expr
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue