From 9f5272b84805d2c1a631cbbc8aa10148bfd5354b Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Tue, 17 Dec 2024 01:35:42 +0530 Subject: [PATCH] Remove unreachable code in `_transform_ti_states` Small improvements in airflow/api_fastapi/common/parameters.py:_transform_ti_states --- airflow/api_fastapi/common/parameters.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airflow/api_fastapi/common/parameters.py b/airflow/api_fastapi/common/parameters.py index cfed2d5e4fc75..c399a080eca07 100644 --- a/airflow/api_fastapi/common/parameters.py +++ b/airflow/api_fastapi/common/parameters.py @@ -536,16 +536,17 @@ def _transform_dag_run_states(states: Iterable[str] | None) -> list[DagRunState # TI def _transform_ti_states(states: list[str] | None) -> list[TaskInstanceState | None] | None: + """Transform a list of state strings into a list of TaskInstanceState enums handling special 'None' cases.""" + if not states: + return None + try: - if not states: - return None return [None if s in ("none", None) else TaskInstanceState(s) for s in states] except ValueError: raise HTTPException( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=f"Invalid value for state. Valid values are {', '.join(TaskInstanceState)}", ) - return states QueryTIStateFilter = Annotated[