You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amcraig (via GitHub)" <gi...@apache.org> on 2025/10/22 08:50:35 UTC
[D] Airflow Incompatibility with Pylance/Pyright [airflow]
GitHub user amcraig created a discussion: Airflow Incompatibility with Pylance/Pyright
### Apache Airflow version
3.1.0
### If "Other Airflow 2/3 version" selected, which one?
This also occurs in 2.11
### What happened?
This drives me nuts, Pylance doesn't seem to be able to pick up correct stubs/typing for Airflow.
Ruff doesn't have issues with the code.
I have ensured VSCode is using the correct PythonPath for my Airflow project.
Common issues include:
- XCom typing between Tasks
- ObjectStoragePath and UPath type differences
- DAG operators `>>` are flagged as not being supported for the tasks
- Complains about unused values in DAG definitions
Is there anything I can do to alleviate this, or am I faced with just ignoring/turning off my linter for Airflow development?
Here's an example DAG which throws Pylance linting error:
<img width="872" height="826" alt="Image" src="https://github.com/user-attachments/assets/1a0a6558-c1af-4110-8731-33136507d1da" />
### What you think should happen instead?
I'd expect that Airflow should work nicely with Pylance/Pyright.
### How to reproduce
Just create a simple DAG like the one in the screenshot provided using ObjectStorage.
An easy linting error is to reproduce is to return a ObjectStoragePath from one task and consume that same ObjectStoragePath in the next task.
The Type of the ObjectStoragePath seems to be lost after passing through XComs
### Operating System
MacOS
### Versions of Apache Airflow Providers
apache-airflow-providers-google==18.0.0
apache-airflow-providers-standard==1.8.0
### Deployment
Virtualenv installation
### Deployment details
This is just experienced in local dev
### 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](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
GitHub link: https://github.com/apache/airflow/discussions/57038
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "amcraig (via GitHub)" <gi...@apache.org>.
GitHub user amcraig added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Makes sense.
I was stuck on thinking it was importable.
Thanks for the help
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14751823
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
GitHub user ashb added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Try creating a virtual env with Airflow installed, and the explicitly setting the python interpreter to that venv'd python. That seems to do the trick for me with neovim and basedpyright.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14807931
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
GitHub user potiuk added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Converted to a dicussion - if more discussion is needed.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14748719
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
GitHub user potiuk edited a comment on the discussion: Airflow Incompatibility with Pylance/Pyright
Use Mypy instead. This is what we use, check and run in our CI.
There is a Mypy VS Code extension as far as I know that uses MyPy Daemon.
We have MyPy plugins that support those "Airflow" things - this is why it works nicer (despite all the MyPy shortcomings). And last time we checked MyPy is the only one that support plugins that allow us to implement some of the checks you mentioned. We spoke to both PyRefly (Facebook) and Ty (Astral) teams and while PyRefly team is kinda open to add plugins in the near fuiture, Ty will not have plugins for quite long time after it is out of beta.
But If you have other ways, it would be great to contribute it. We are also looking towards ty, pyrefly as replacements for mypy - but lack of plugin support that would allow us to make those things work made it so far not very appealing despite the speed. However maybe things changes - if you would like to invest in Pyrefly or Ty replacement, that would be a good contribution - both of them fully suport Language Server Specification so should nicely fit VSCode.
I believe - unfortunately - pylance/pyright does not support plugins, otherwise we would also welcome someone who really wants to use pyright to contribute plugins to support those things.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14748716
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
GitHub user potiuk added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
I think you shoudl copy it to your project and use it as any other plugin - we do not have it packaged. We even have an open issue to make it easier to use - and it's up for grabs for anyone who will figure it out and contribute a better way. Contributions like that are always most welcome: https://github.com/apache/airflow/issues/38796
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14751812
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
GitHub user potiuk added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Use Mypy instead. This is what we use, check and run in our CI.
There is a Mypy VS Code extension as far as I know that uses MyPy Daemon.
We have MyPy plugins that support those "Airflow" things - this is why it works nicer (despite all the MyPy shortcomings). And last time we checked MyPy is the only one that support plugins that allow us to implement some of the checks you mentioned. We spoke to both PyRefly (Facebook) and Ty (Astral) teams and while PyRefly team is kinda open to add plugins in the near fuiture, Ty will not have plugins for quite long time after it is out of beta.
But If you have other ways, it would be great to contribute it. We are also looking towards ty, pyrefly as replacements for mypy - but lack of plugin support that would allow us to make those things work made it so far not very appealing despite the speed. However maybe things changes - if you would like to invest in Pyrefly or Ty replacement, that would be a good contribution - both of them fully suport Language Server Specification so should nicely fit VSCode.
I believe - unfortunately - pyright does not support plugins, otherwise we would also welcome someone who really wants to use pyright to contribute plugins to support those things.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14748716
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
GitHub user boring-cyborg[bot] added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14748715
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
GitHub user potiuk added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Mypy plugins here: https://github.com/apache/airflow/tree/main/dev/airflow_mypy
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14748754
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "amcraig (via GitHub)" <gi...@apache.org>.
GitHub user amcraig added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Thanks for all the info and suggestions @potiuk that's just what I needed to know; really appreciated!
I'll have my team try swapping over to Mypy, and then investigate into Ty as it matures, as we're already in the Astral stack.
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14750452
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org
Re: [D] Airflow Incompatibility with Pylance/Pyright [airflow]
Posted by "amcraig (via GitHub)" <gi...@apache.org>.
GitHub user amcraig added a comment to the discussion: Airflow Incompatibility with Pylance/Pyright
Actually, quick question @potiuk :
What path do I use to include the Mypy Airflow Plugin.
Is it installable via the pip package, or do I have to clone the repo to point to a absolute path?
GitHub link: https://github.com/apache/airflow/discussions/57038#discussioncomment-14751697
----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org