-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Fix TypeError: unhashable type: 'dict' in Asset.__hash__()
#60562
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
base: main
Are you sure you want to change the base?
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
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.
Pull request overview
This PR fixes a TypeError in Asset.__hash__() that was attempting to hash a dictionary directly. The fix serializes the attrs dictionary to a JSON string using json.dumps(sort_keys=True) before hashing, following the pattern used elsewhere in the codebase.
Changes:
- Modified
Asset.__hash__()to usejson.dumps()for serializing the dictionary before hashing - Added tests for hash equality with same and different URIs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| task-sdk/src/airflow/sdk/definitions/asset/init.py | Added json import and modified __hash__ to serialize dictionary using json.dumps(sort_keys=True) |
| task-sdk/tests/task_sdk/definitions/test_asset.py | Added two test cases to verify hash behavior for same and different URIs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Apologies - the Copilot review comment was automatically generated by my GitHub account settings when I created this PR. This was unintentional. If this is an issue for the project, I can disable Copilot and resubmit the PR. Please let me know if you'd like me to take any action. |
acbd703 to
adda76d
Compare
What change does this PR introduce?
airflow.sdk.definitions.asset.Asset.__hash__()in task-sdk which was attempting to hash a dictionary directly, causing aTypeError.__eq__implementation.Changes
__hash__to serialize the attrs dictionary to JSON string usingjson.dumps(sort_keys=True)before hashing.Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.