diff --git a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs index 9f87bb6073..33beb8b3b1 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -113,7 +113,11 @@ pub(crate) fn lambda_assignment( // See: https://github.com/astral-sh/ruff/issues/3046 // See: https://github.com/astral-sh/ruff/issues/5421 if (annotation.is_some() && checker.semantic().scope().kind.is_class()) - || checker.semantic().scope().has(id) + || checker + .semantic() + .scope() + .get_all(id) + .any(|binding_id| checker.semantic().binding(binding_id).kind.is_annotation()) { diagnostic.set_fix(Fix::manual(Edit::range_replacement(indented, stmt.range()))); } else { @@ -139,9 +143,9 @@ fn extract_types(annotation: &Expr, semantic: &SemanticModel) -> Option<(Vec Option<(Vec elts.clone(), Expr::Constant(ast::ExprConstant { value: Constant::Ellipsis, @@ -165,9 +169,9 @@ fn extract_types(annotation: &Expr, semantic: &SemanticModel) -> Option<(Vec