mypy errors - Argument 1 has incompatible type "XComArg"
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.8.1
What happened?
Ever since upgrading to 2.8.1. from 2.7.3. we are experiencing a number of mypy errors regarding arg types, mainly
error: Argument 1 has incompatible type "XComArg"; expected "dict[Any, Any]" [arg-type]
We use TaskFlow API and define the task dependencies exactly as in the example tutorial taskflow dag
order_data = extract()
order_summary = transform(order_data)
load(order_summary["total_order_value"])
and haven't changed anything else in our DAG definitions.
What you think should happen instead?
No such errors should be raised, as was the case in 2.7.3.
How to reproduce
Run mypy on the tutorial taskflow DAG https://github.com/apache/airflow/blob/main/airflow/example_dags/tutorial_taskflow_api.py module
Operating System
Ubuntu 22.04
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
This was solved by https://github.com/apache/airflow/pull/26023 but that code was moved under the dev directory by https://github.com/apache/airflow/pull/28498. AFAIK the code from that directory isn't included in any kind of public release.
FWIW there are 2 workaround. You could copy that code into your own Airflow repo or just use cast on the operator as it's passed into the task method.
This was solved by #26023 but that code was moved under the
devdirectory by #28498. AFAIK the code from that directory isn't included in any kind of public release.FWIW there are 2 workaround. You could copy that code into your own Airflow repo or just use
caston the operator as it's passed into the task method.
We have a task about mypy plugin https://github.com/apache/airflow/issues/38796
Yeah. Duplicate.