mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Add PYI034 for flake8-pyi
plugin (#4764)
This commit is contained in:
parent
c68686b1de
commit
fcbf5c3fae
14 changed files with 918 additions and 2 deletions
|
@ -684,12 +684,27 @@ pub fn collect_arg_names<'a>(arguments: &'a Arguments) -> FxHashSet<&'a str> {
|
|||
/// callable.
|
||||
pub fn map_callable(decorator: &Expr) -> &Expr {
|
||||
if let Expr::Call(ast::ExprCall { func, .. }) = decorator {
|
||||
// Ex) `@decorator()`
|
||||
func
|
||||
} else {
|
||||
// Ex) `@decorator`
|
||||
decorator
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
pub fn map_subscript(expr: &Expr) -> &Expr {
|
||||
if let Expr::Subscript(ast::ExprSubscript { value, .. }) = expr {
|
||||
// Ex) `Iterable[T]`
|
||||
value
|
||||
} else {
|
||||
// Ex) `Iterable`
|
||||
expr
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if a statement or expression includes at least one comment.
|
||||
pub fn has_comments<T>(located: &T, locator: &Locator) -> bool
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue