-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Conversation
…cutors" This reverts commit a1c532e.
airflow/providers/apache/cassandra/example_dags/example_cassandra_dag.py
Outdated
Show resolved
Hide resolved
|
||
try: | ||
conn: "Optional[Connection]" = self.get_connection(conn_id) |
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 a get_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?
Conflict to solve, I am afraid @subkanthi :( |
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease. |
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.
Coudl you please remove the docker change and rebase?
Fixes mypy in
related: #19891
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.