[ty] Tighten up validation of subscripts and attributes in type expressions (#24329)

This commit is contained in:
Alex Waygood
2026-04-01 20:01:20 +01:00
committed by GitHub
parent c66bc41ec3
commit 298d1cebce
9 changed files with 107 additions and 57 deletions
+8
View File
@@ -1681,6 +1681,14 @@ pub fn comment_indentation_after(
.unwrap_or_default()
}
pub fn is_dotted_name(expr: &ast::Expr) -> bool {
match expr {
ast::Expr::Name(_) => true,
ast::Expr::Attribute(ast::ExprAttribute { value, .. }) => is_dotted_name(value),
_ => false,
}
}
#[cfg(test)]
mod tests {
use std::borrow::Cow;