Skip to content

[airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303)#22453

Merged
ntBre merged 6 commits intoastral-sh:mainfrom
sjyangkevin:check-second-pos-arg-in-asset-dataset
Jan 17, 2026
Merged

[airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303)#22453
ntBre merged 6 commits intoastral-sh:mainfrom
sjyangkevin:check-second-pos-arg-in-asset-dataset

Conversation

@sjyangkevin
Copy link
Contributor

@sjyangkevin sjyangkevin commented Jan 8, 2026

Summary

This PR is related to apache/airflow#48389.

In Airflow 3, the function signature for airflow.Dataset, airflow.datasets.Dataset, and airflow.sdk.Asset has changed. Below is the function signature for airflow.sdk.Asset. The second positional argument is uri which is of type str. In the older version, the second positional argument can be a dictionary which is the extra: 'dict | None' = None argument. Therefore, we need to flag this in Airflow 3.

Asset(name: 'str | None' = None, uri: 'str | None' = None, *, group: 'str | None' = None, extra: 'dict | None' = None, watchers: 'list[AssetWatcher | SerializedAssetWatcher] | None' = None) -> 'None'

As this is a check on constructor call, we need to create a new method check_constructor_arguments, instead of on method call. The new rule check whether the index 1 (the second argument) is a dictionary (either a literal or a dict() call).

Test Plan

The AIR303.py test file have been updated with new test cases. The snapshot has been updated and all other test cases passed.

@Lee-W , could you please review it when you have a chance, and let me know if you have further feedback. Thanks!

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 8, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit, LGTM!

@sjyangkevin sjyangkevin force-pushed the check-second-pos-arg-in-asset-dataset branch from dafc4b3 to cf31b81 Compare January 8, 2026 15:33
@sjyangkevin sjyangkevin requested a review from Lee-W January 8, 2026 15:49
@amyreese amyreese added the rule Implementing or modifying a lint rule label Jan 8, 2026
Copy link
Contributor

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the last nit 👍 Thanks!

@MichaReiser MichaReiser requested a review from ntBre January 9, 2026 16:36
@ntBre ntBre added the preview Related to preview mode features label Jan 15, 2026
Copy link
Contributor

@ntBre ntBre left a 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 good to me overall, just a couple of minor suggestions about additional cases you could handle, if you want.

@sjyangkevin sjyangkevin force-pushed the check-second-pos-arg-in-asset-dataset branch from 28524a4 to 54274a1 Compare January 15, 2026 22:45
@sjyangkevin sjyangkevin requested review from Lee-W and ntBre January 15, 2026 23:07
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, if @Lee-W is happy with it too! Thank you!

Asset("asset1")
Asset("asset1", extra={"key": "value"})
Asset(uri="asset1", extra={"key": "value"})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

nit: additional blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. thanks for caching it.

Copy link
Contributor

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took a look again. LGTM. Thanks all!

@sjyangkevin sjyangkevin force-pushed the check-second-pos-arg-in-asset-dataset branch from 54274a1 to 60f8ec2 Compare January 17, 2026 17:33
@ntBre ntBre changed the title [airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303) [airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303) Jan 17, 2026
@ntBre ntBre merged commit 704d30f into astral-sh:main Jan 17, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants