multimeric commented on issue #19884:
URL: https://github.com/apache/airflow/issues/19884#issuecomment-3822015329

   For the latter problem: "I'd like Airflow to warn me about the type 
conflicts at parse time", I think the first step is to propagate the return 
type into the `XComArg`.
   
   Currently the decorated tasks preserve their return types:
   
   
https://github.com/apache/airflow/blob/4e32b681b7a9b89f86d820a14848fe8655a19133/task-sdk/src/airflow/sdk/bases/decorator.py#L349-L351
   
   But once it's called within a DAG, it loses its type:
   
https://github.com/apache/airflow/blob/4e32b681b7a9b89f86d820a14848fe8655a19133/task-sdk/src/airflow/sdk/bases/decorator.py#L405
   
   It would be easy enough to make `XComArg` generic and then return 
`XComArg[FReturn]`.
   
   This doesn't completely solve the problem because the type checker won't 
consider `XComArg[T]` and `T` to be the same, but you could e.g. write a 
utility function that casts one to the other to preserve type safety.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to