mirror of
https://github.com/mtshiba/pylyzer.git
synced 2025-10-15 15:09:06 +00:00
11 lines
317 B
Rust
11 lines
317 B
Rust
use rustpython_parser::ast::Expr;
|
|
|
|
pub fn accessor_name(expr: Expr) -> Option<String> {
|
|
match expr {
|
|
Expr::Name(name) => Some(name.id.to_string()),
|
|
Expr::Attribute(attr) => {
|
|
accessor_name(*attr.value).map(|value| format!("{value}.{}", attr.attr))
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|