Skip to content

Commit

Permalink
Check that airflow module is seen for AIR001 (#14627)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila authored Nov 27, 2024
1 parent 82c01aa commit 0d649f9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast as ast;
use ruff_python_ast::Expr;
use ruff_python_semantic::Modules;
use ruff_text_size::Ranged;

use crate::checkers::ast::Checker;
Expand Down Expand Up @@ -49,6 +50,10 @@ pub(crate) fn variable_name_task_id(
targets: &[Expr],
value: &Expr,
) -> Option<Diagnostic> {
if !checker.semantic().seen_module(Modules::AIRFLOW) {
return None;
}

// If we have more than one target, we can't do anything.
let [target] = targets else {
return None;
Expand All @@ -69,7 +74,7 @@ pub(crate) fn variable_name_task_id(
if !checker
.semantic()
.resolve_qualified_name(func)
.is_some_and(|qualified_name| matches!(qualified_name.segments()[0], "airflow"))
.is_some_and(|qualified_name| matches!(qualified_name.segments(), ["airflow", ..]))
{
return None;
}
Expand Down

0 comments on commit 0d649f9

Please sign in to comment.