Implement PEP 604 annotation rewrites (#369)

This commit is contained in:
Charlie Marsh 2022-10-08 20:28:00 -04:00 committed by GitHub
parent 806f3fd4f6
commit 7fe5945541
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 324 additions and 18 deletions

9
src/ast/helpers.rs Normal file
View file

@ -0,0 +1,9 @@
use rustpython_ast::{Expr, ExprKind};
pub fn match_name_or_attr(expr: &Expr, target: &str) -> bool {
match &expr.node {
ExprKind::Attribute { attr, .. } => target == attr,
ExprKind::Name { id, .. } => target == id,
_ => false,
}
}