airflow icon indicating copy to clipboard operation
airflow copied to clipboard

mypy errors - Argument 1 has incompatible type "XComArg"

Open ampx-mg opened this issue 1 year ago • 2 comments

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

ampx-mg avatar May 09 '24 08:05 ampx-mg

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.

jonathan-ostrander avatar May 13 '24 17:05 jonathan-ostrander

This was solved by #26023 but that code was moved under the dev directory 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 cast on the operator as it's passed into the task method.

We have a task about mypy plugin https://github.com/apache/airflow/issues/38796

eladkal avatar May 15 '24 05:05 eladkal

Yeah. Duplicate.

potiuk avatar Jul 30 '24 18:07 potiuk