refactor: extract _add_test_tasks to reduce build_airflow_graph complexity#2734
refactor: extract _add_test_tasks to reduce build_airflow_graph complexity#2734Aaditya-git wants to merge 2 commits into
Conversation
…exity Extracts the test-behavior branching block from build_airflow_graph into a dedicated _add_test_tasks helper, reducing cyclomatic complexity from 11 to 9 and removing the noqa: C901 suppression. Closes astronomer#1943
|
Thanks for tackling #1943, @Aaditya-git, and apologies for the duplicated effort here. This overlaps almost entirely with #2689, which was opened earlier (May 16) and is solving the same issue the same way: extracting the test-task branches into a new To avoid two contributors maintaining the same refactor, I'm going to close this in favor of #2689. This isn't a reflection on the quality of your change, the approach is sound. Looking forward to your continued contributions to the project. |
Summary
Closes #1943
build_airflow_graphhad a cyclomatic complexity of 11, exceeding the ruff C901 limit of 10 and requiring a# noqa: C901suppression comment.This PR extracts the test-behavior branching block into a dedicated
_add_test_taskshelper function, reducingbuild_airflow_graph's complexity from 11 to 9 and removing the suppression comment.Changes
cosmos/airflow/graph.py: new_add_test_tasksfunction handles bothAFTER_ALLandBUILD/AFTER_EACHtest behavior cases.build_airflow_graphnow calls it in one line instead of ~40 lines of inline branching. The# noqa: C901comment is removed.No behavior changes
This is a pure refactor. All existing logic is preserved verbatim inside
_add_test_tasks, the only difference is where the code lives. All existing tests forbuild_airflow_graphcontinue to cover the same behavior paths.