-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[airflow] Passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)
#22046
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
[airflow] Passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)
#22046
Conversation
airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)airflow] passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
|
631859e to
dc906c4
Compare
|
Hi @Lee-W , @ntBre , I've made the following updates to the PR. The updates might be more than what we've discussed, but please let me know if you have further feedback. Thanks for your time to review. Updates
I think again based on the following trade-off, I feel make it a Option 1: make it a message
Option 2: make a "full replacement"
|
Lee-W
left a 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.
Left a few comments, but looks way better! Thanks!
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
dc906c4 to
e20c94b
Compare
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Show resolved
Hide resolved
ntBre
left a 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.
Thank you! This looks great to me overall, I just had a few small suggestions.
crates/ruff_linter/resources/test/fixtures/airflow/AIR303_args.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/airflow/AIR303_args.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
e20c94b to
939f14c
Compare
|
Thanks @ntBre, I've made the following changes based on the feedback.
if let ["airflow", "lineage", "hook", "HookLineageCollector"] = qualified_name.segments() {
if attr.as_str() == "create_asset" && has_positional_args {
...
@Lee-W , would you mind have a look into these changes whenever you have time, and let me know if you have further feedback? Thanks again for both your time in reviewing this! |
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
ntBre
left a 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.
Thank you, this looks great!
I just had a couple more nits after we mark the rule as preview. Otherwise this is good to go if @Lee-W is happy with it too :)
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/airflow/rules/function_signature_change_in_3.rs
Outdated
Show resolved
Hide resolved
|
will take another look early tomorrow. Thanks! |
…ges that only accept keyword arguments
8f737db to
59c7f95
Compare
|
Thanks @ntBre , I've made the following updates based on your feedback.
|
Lee-W
left a 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.
LGTM! Thanks @sjyangkevin and @ntBre !
ntBre
left a 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.
Thank you!
airflow] passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)airflow] Passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR303)

Summary
This is a follow up PR to #21096
The new code AIR303 is added for checking function signature change in Airflow 3.0. The new rule added to AIR303 will check if positional argument is passed into
airflow.lineage.hook.HookLineageCollector.create_asset. Since this method is updated to accept only keywords argument, passing positional argument into it is not allowed, and will raise an error. The test is done by checking whether positional argument with 0 index can be found.Test Plan
A new test file is added to the fixtures for the code AIR303. Snapshot test is updated accordingly.