Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

Mypy issue on main:

airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:311: error: Item "DictOfListsExpandInput" of
"SchedulerDictOfListsExpandInput | SchedulerListOfDictsExpandInput | DictOfListsExpandInput | ListOfDictsExpandInput" has no attribute "get_total_map_length"  [union-attr]
                    mapped_ti_count = upstream_mapped_group._expand_input.get_total_map_length(
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:311: error: Item "ListOfDictsExpandInput" of
"SchedulerDictOfListsExpandInput | SchedulerListOfDictsExpandInput | DictOfListsExpandInput | ListOfDictsExpandInput" has no attribute "get_total_map_length"  [union-attr]
                    mapped_ti_count = upstream_mapped_group._expand_input.get_total_map_length(

Adding a type cast to help mypy understand that upstream_mapped_group._expand_inputis a SchedulerExpandInput at runtime which has get_total_map_length defined.

Safe cast because at runtime the expand input will always be a SchedulerExpandInput, we just need to help mypy understand this.

Example failure: https://github.com/apache/airflow/actions/runs/16221450919/job/45803515859


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@amoghrajesh amoghrajesh requested review from ashb and kaxil as code owners July 11, 2025 14:43
@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Jul 11, 2025
@gopidesupavan
Copy link
Member

lets see i will rebase mypy bump on this hopefully 🤞

@gopidesupavan gopidesupavan merged commit 8d18c69 into apache:main Jul 11, 2025
102 checks passed
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
)

* Add type casting for mypy to understand upstream_mapped_group._expand_input

* Add type casting for mypy to understand upstream_mapped_group._expand_input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants