mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-22 00:02:17 +00:00
Re-integrate RustPython parser repository (#4359)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
865205d992
commit
be6e00ef6e
270 changed files with 3061 additions and 3361 deletions
|
@ -1,4 +1,4 @@
|
|||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
use rustpython_parser::ast::{self, Expr, ExprKind};
|
||||
use smallvec::smallvec;
|
||||
|
||||
/// A representation of a qualified name, like `typing.List`.
|
||||
|
@ -6,16 +6,16 @@ pub type CallPath<'a> = smallvec::SmallVec<[&'a str; 8]>;
|
|||
|
||||
fn collect_call_path_inner<'a>(expr: &'a Expr, parts: &mut CallPath<'a>) -> bool {
|
||||
match &expr.node {
|
||||
ExprKind::Attribute { value, attr, .. } => {
|
||||
ExprKind::Attribute(ast::ExprAttribute { value, attr, .. }) => {
|
||||
if collect_call_path_inner(value, parts) {
|
||||
parts.push(attr);
|
||||
parts.push(attr.as_str());
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
ExprKind::Name { id, .. } => {
|
||||
parts.push(id);
|
||||
ExprKind::Name(ast::ExprName { id, .. }) => {
|
||||
parts.push(id.as_str());
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue