-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Fxing MyPy issues inside airflow/providers/qubole #20625
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
Conversation
| ) | ||
|
|
||
| template_ext: Iterable[str] = ('.txt',) | ||
| template_ext: Sequence[str] = ('.txt',) |
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.
Maybe this should have been Collection instead of Sequence? Or does anything in Airflow requires these to be deterministically ordered?
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 field is defined in the base class as Sequence. It used to be Iterable and was changed here. I changed it to match base class and not sure if order here metters at all. BTW, it was suggested by you :) #20034 (comment)
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.
Yep. I already implemented Sequence for ALL operators in #20571 :).
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.
And #20608
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.
So better not change it again - unless we have a good reason to.
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.
The reason for below set-tuple conversion is to remove any duplicates and hence set with union operator was used prior to conversion. It's similar to one in here:
airflow/airflow/providers/qubole/operators/qubole_check.py
Lines 108 to 110 in 84a4bcc
| template_fields: Sequence[str] = tuple( | |
| set(QuboleOperator.template_fields) | set(SQLCheckOperator.template_fields) | |
| ) |
Well, it also means that if we dont need dups then Set type would be more appropriate
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 we choose another protocol - fine with me. That''s yet andother 280 files change :) .
Anyone happy to do it ?
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 can change them to Set type if we are in an agreement?
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 a caution I will also need to change the type of values it (template_fields) gets assigned to, which are mostly tuple and will become all set. Also documentation needs to be amended as there were no much emphasis on the type of these fields and list also were used: https://airflow.apache.org/docs/apache-airflow/stable/concepts/operators.html#jinja-templating
This means we also need to notify users about this change.
Alternatively, we can leave them as is and let users to use list, tuple etc. to provide simplicity of use and internally carry on removing duplicates as they (dups) dont make any sense. WDYT?
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’d say let’s keep Sequence and do the mass-change later. That makes the commit history easier to reason with.
|
Looks good. Here the first try to fix Qubole |
Part of #19891
tupleconversion to adhere to the type of the field:Sequence[str]^ 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.