-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix completion/linting/type checking with VSCode/pyright #43899
Conversation
cc @JDarDagran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for VSCode user with Pylance enabled - it fixed the issue. Thank you a lot @ashb 🚀
Okay sadly we can't do this. By creating this empty file pycharm thinks Okay, think I might have it fixed now. |
c3c9847
to
a8f5231
Compare
Pyright (the type engine powering VSCode's python extension) doesn't treat `airflow` as a namespace package because of the `airflow/__init__.py` and it doesn't want to/can't support detecting the `__path__ = ...` method of making it an explicit namespace package, so we are left with no option but to create Yet Another Stub File. Tested by pytting `reveal_type(FAB_VERSION); reveal_type(TaskSDKDag)` inside `_upgrade_outdated_dag_access_control` in `airflow/model/dag.py` -- before this change it was reporting both as Unknown. And to continue to keep Pycharm happy we have to have the `__path__` stanzas without future annotations in all the "empty" files. Ugly, but at least it works
a8f5231
to
73eb25b
Compare
@@ -660,7 +660,7 @@ function install_airflow() { | |||
|
|||
# Similarly we need _a_ file for task_sdk too | |||
mkdir -p ./task_sdk/src/airflow/sdk/ | |||
touch ./task_sdk/src/airflow/__init__.py | |||
touch ./task_sdk/src/airflow/sdk/__init__.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path was okay before, but since I added exclude = ["src/airflow/__init__.py"]
in this PR this path now needs to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pycharm test works as expected as discussed offline. LGTM
Static check failure unrelated and will be fixed by #43923 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Getting it right with PyCharm, VSCode namespace packages and static checks and CLI seems like an interesting game :)
Pyright (the type engine powering VSCode's python extension) doesn't treat `airflow` as a namespace package because of the `airflow/__init__.py` and it doesn't want to/can't support detecting the `__path__ = ...` method of making it an explicit namespace package, so we are left with no option but to create Yet Another Stub File. Tested by pytting `reveal_type(FAB_VERSION); reveal_type(TaskSDKDag)` inside `_upgrade_outdated_dag_access_control` in `airflow/model/dag.py` -- before this change it was reporting both as Unknown. And to continue to keep Pycharm happy we have to have the `__path__` stanzas without future annotations in all the "empty" files. Ugly, but at least it works
Pyright (the type engine powering VSCode's python extension) doesn't treat `airflow` as a namespace package because of the `airflow/__init__.py` and it doesn't want to/can't support detecting the `__path__ = ...` method of making it an explicit namespace package, so we are left with no option but to create Yet Another Stub File. Tested by pytting `reveal_type(FAB_VERSION); reveal_type(TaskSDKDag)` inside `_upgrade_outdated_dag_access_control` in `airflow/model/dag.py` -- before this change it was reporting both as Unknown. And to continue to keep Pycharm happy we have to have the `__path__` stanzas without future annotations in all the "empty" files. Ugly, but at least it works
Pyright (the type engine powering VSCode's python extension) doesn't treat
airflow
as a namespace package because of theairflow/__init__.py
and itdoesn't want to/can't support detecting the
__path__ = ...
method of makingit an explicit namespace package, so we are left with no option but to create
Yet Another Stub File.
Tested by pytting
reveal_type(FAB_VERSION); reveal_type(TaskSDKDag)
inside_upgrade_outdated_dag_access_control
inairflow/model/dag.py
-- beforethis change it was reporting both as Unknown.