Skip to content

Remove unreachable break in get_bagged_dag - #72332

Open
henry3260 wants to merge 1 commit into
apache:mainfrom
henry3260:remove-unreachable-break-in-get-bagged-dag
Open

Remove unreachable break in get_bagged_dag#72332
henry3260 wants to merge 1 commit into
apache:mainfrom
henry3260:remove-unreachable-break-in-get-bagged-dag

Conversation

@henry3260

Copy link
Copy Markdown
Contributor

Why

The second bundle loop in get_bagged_dag ends with:

if dag := dagbag.dags.get(dag_id):
    return dag
if dag:
    break

The walrus assignment returns as soon as a Dag is found, so if dag: is only ever reached when dag is falsy — the break cannot run. The first bundle loop in the same function already uses the plain early return, so removing it also makes the two loops read the same way.

What

  • airflow-core/src/airflow/utils/cli.py: dropped the unreachable if dag: break from get_bagged_dag. No behavior change — the intent (stop searching once the Dag is found) is already served by the return, so no tests are added.

The walrus assignment on the preceding line returns as soon as a Dag is
found, so the following `if dag:` is only ever reached when `dag` is
falsy and its `break` can never run. Dropping it also makes the two
bundle loops in this function read the same way.
@henry3260
henry3260 force-pushed the remove-unreachable-break-in-get-bagged-dag branch from 7cf5bd2 to c7830b7 Compare August 31, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant