Implement flake8-future-annotations FA100 (#3979)

This commit is contained in:
Tyler Yep 2023-05-13 20:00:06 -07:00 committed by GitHub
parent cd2e7fa72a
commit 01b372a75c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 375 additions and 15 deletions

View file

@ -70,6 +70,15 @@ pub fn is_pep585_builtin(expr: &Expr, context: &Context) -> bool {
})
}
/// Returns `true` if `Expr` represents a reference to a typing object with a
/// PEP 603 built-in.
pub fn is_pep604_builtin(expr: &Expr, context: &Context) -> bool {
context.resolve_call_path(expr).map_or(false, |call_path| {
context.match_typing_call_path(&call_path, "Optional")
|| context.match_typing_call_path(&call_path, "Union")
})
}
pub fn is_immutable_annotation(context: &Context, expr: &Expr) -> bool {
match &expr.node {
ExprKind::Name(_) | ExprKind::Attribute(_) => {