Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jul 24, 2024
1 parent a2a6aaf commit bb14c21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::name::{QualifiedName, QualifiedNameBuilder};
use ruff_python_ast::statement_visitor::StatementVisitor;
use ruff_python_ast::visitor::Visitor;
use ruff_python_ast::{self as ast, Expr};
use ruff_python_semantic::{Exceptions, Modules, NodeId, SemanticModel};
Expand Down Expand Up @@ -874,6 +875,13 @@ impl Visitor<'_> for AttributeSearcher<'_> {
}
ast::visitor::walk_expr(self, expr);
}

fn visit_stmt(&mut self, stmt: &ruff_python_ast::Stmt) {
if self.found_attribute {
return;
}
ast::visitor::walk_stmt(self, stmt);
}
}

/// Given an [`ast::StmtTry`] node, does the `try` branch of that node
Expand Down Expand Up @@ -919,7 +927,7 @@ impl<'a> ImportSearcher<'a> {
}
}

impl Visitor<'_> for ImportSearcher<'_> {
impl StatementVisitor<'_> for ImportSearcher<'_> {
fn visit_stmt(&mut self, stmt: &ast::Stmt) {
if self.found_import {
return;
Expand All @@ -934,6 +942,6 @@ impl Visitor<'_> for ImportSearcher<'_> {
return;
}
}
ast::visitor::walk_stmt(self, stmt);
ast::statement_visitor::walk_stmt(self, stmt);
}
}

0 comments on commit bb14c21

Please sign in to comment.