[airflow] passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR301)#21096
Conversation
|
…e_asset has positional arguments
e224675 to
4114892
Compare
airflow] passing positional argument into airflow.lineage.hook.HookLineageCollector.create_asset is not allowed (AIR301)
MichaReiser
left a comment
There was a problem hiding this comment.
I haven't followed the airflow PRs closely so I don't know if this is the first check for positional arguments.
Did airflow 2 allow position arguments but airflow 3 does no more?
I can see how this check is useful but it's something a type checker could catch too.
| 59 | hlc.create_asset("should", "be", "no", "posarg") | ||
| 60 | hlc.create_asset(name="but", uri="kwargs are ok") | ||
| | | ||
| help: Calling ``HookLineageCollector.create_asset`` with positional argument should raise an error |
There was a problem hiding this comment.
Is this the intended message you want to show to users? Shouldn't it say instead that position arguments are disallowed?
There was a problem hiding this comment.
Let me reword it again
There was a problem hiding this comment.
After reading the whole message yet again, we should probably add a AIR303 for function signature change. I have another local branch working on something similar and moving this one there might be better as create_asset is not removed. Only its signature changed.
WDTY?
There was a problem hiding this comment.
Agree, AIR301 feels out of place for a signature change because it's not a removal
Yes, I think this is the first one
Yes.
Yes, but we think it would still be helpful if these rules can also detect it here. As most of our users would be data engineers and might not care type checking that much |
Fair enough. I'd prefer a separate rule because that would also make it easier to deprecate said rule when we introduce a general-purpose rule that detects positional arguments that should have been passed as keyword arguments (which we already have in ty) |
|
Thanks for working on this PR. I'll close this PR as it seems stale. @Lee-W, don't hesitate to submit a new PR if you plan to get back to this. |
|
thank you @Lee-W for working on this, and thank you @MichaReiser for sharing the feedback. I discussed with @Lee-W , and I would like to pick up the work for adding this rule. As I am new to ruff, so I am still reviewing the contribution guide, and would like to start by asking some basic questions. Create a new code AIR303I am wondering if I need to open an issue to discuss the creation of the code AIR303 before starting the implementation. Have we decided on the naming for the new rule (e.g., detect_positional_argument, ...)? High-level thinking on implementationFrom my high-level understanding, the new code could be added to the ruff/crates/ruff_linter/src/codes.rs Lines 1119 to 1124 in c7eea1f Thanks, |
I think we're good? given that I didn't create an issue for this one.
function_signature_change or something similar might be better |
…okLineageCollector.create_asset` is not allowed (`AIR303`) (#22046) ## 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. <img width="1444" height="513" alt="Screenshot from 2025-12-17 20-54-48" src="https://github.com/user-attachments/assets/bc235195-e986-4743-9bf7-bba65805fb87" /> <img width="981" height="433" alt="Screenshot from 2025-12-17 21-34-29" src="https://github.com/user-attachments/assets/492db71f-58f2-40ba-ad2f-f74852fa5a6b" />
…okLineageCollector.create_asset` is not allowed (`AIR303`) (#22046) ## Summary This is a follow up PR to astral-sh/ruff#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. <img width="1444" height="513" alt="Screenshot from 2025-12-17 20-54-48" src="https://github.com/user-attachments/assets/bc235195-e986-4743-9bf7-bba65805fb87" /> <img width="981" height="433" alt="Screenshot from 2025-12-17 21-34-29" src="https://github.com/user-attachments/assets/492db71f-58f2-40ba-ad2f-f74852fa5a6b" />
…e_asset has positional arguments
Summary
airflow.lineage.hook.HookLineageCollector.create_assetis not allowedTest Plan
update the test fixture accordingly and reorganize in the next commit