Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 mypy providers #20190
Fix mypy providers #20190
Changes from 14 commits
a1c532e
6cbb506
d16a343
a336e17
382eedf
c3030fb
1c3c029
0eb6598
8ef0bcc
c719166
a503ef5
37e2fc6
3c976c5
3638cd0
f8cba96
31ad8db
6a117e4
35a344e
0f60ae4
56b414c
8d47486
b4daedc
7a31cd1
e21a9a8
1fa154a
a997e30
12c628e
dcf537d
f450679
96b7a9b
67c6f5e
dbfdcc5
a09d628
816b976
fa68b40
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
If the stringified typing can safely be removed then the
TYPE_CHECKING
statement can also be removed. You'll need to confirm though with some testing. MyPy should complain if it's an issue.@kaxil @potiuk Another example of
get_connection()
in a hook's__init__()
here. Oddly enough, this hook has aget_conn()
method but it's a null method.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.
I don’t think this is going to work at runtime. The stringified version is still needed.
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.
Hm @josh-fell (and @kaxil ) - Something struck, me I just looked closer at the #18339
I think while discussing it I made a silent assumption (which I see now was wrong ) that the connection was created as part of "operator's" init but this is about creating it in the Hook's init, which IMHO is quite legitimate use case (as long as you do not instantiate the Hook in the operator's init(). And it is pretty common pattern in Airflow (and one we actually encourage).
I double-checked and I looked at the Databricks code and the only place I could see it being instantiated was _get_hook() and the only place where _get_hook() is called was inside "execute" and "on_kill" method of the Databricks operator - so that all sounds pretty legitimate.
Was not the whole issue caused by a misunderstanding of who's init it was? I think we have maaaaany cases where Hook is created "on-demand" in execute() method of the operator, also if you decide to create the Hook() inside the
@task
-decorated functions, it should work really well.Are my eyes cheating me ? O r maybe I miss something?