Skip to content

Commit

Permalink
Make type annotation less confusing in task_command.py (#38561)
Browse files Browse the repository at this point in the history
Previously it declared type as a union on a line where it could only be one type; declaring it above makes it less confusing
  • Loading branch information
dstandish authored Mar 27, 2024
1 parent e364259 commit 07fd17a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions airflow/cli/commands/task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@ def _get_ti(
)

ti_or_none = dag_run.get_task_instance(task.task_id, map_index=map_index, session=session)
ti: TaskInstance | TaskInstancePydantic
if ti_or_none is None:
if not create_if_necessary:
raise TaskInstanceNotFound(
f"TaskInstance for {dag.dag_id}, {task.task_id}, map={map_index} with "
f"run_id or execution_date of {exec_date_or_run_id!r} not found"
)
# TODO: Validate map_index is in range?
ti: TaskInstance | TaskInstancePydantic = TaskInstance(
task, run_id=dag_run.run_id, map_index=map_index
)
ti = TaskInstance(task, run_id=dag_run.run_id, map_index=map_index)
ti.dag_run = dag_run
else:
ti = ti_or_none
Expand Down

0 comments on commit 07fd17a

Please sign in to comment.