🐛 fix requirements equality check in newer version of hatch#100
Conversation
|
Looks like pypa/packaging#1022 is fixing the subclassing issue, |
There was a problem hiding this comment.
Pull request overview
This PR fixes a requirements equality check issue in the compare_requirements method that arose with newer versions of hatch. The fix addresses a problem where direct set equality comparison of Requirement objects no longer works reliably, likely due to changes in the packaging library's equality or hashing behavior.
Key Changes
- Modified the
compare_requirementsmethod to use element-wise equality checking instead of direct set equality - Added documentation explaining the backward compatibility workaround
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hatch_pip_compile/lock.py
Outdated
| For backward compatibility, we ensure sets equality by checking the | ||
| size of sets and set A is a subset of set B. |
There was a problem hiding this comment.
The comment says "set A is a subset of set B" but this is misleading. The implementation actually checks for equality between the two sets: it verifies that both sets have the same size AND every element in requirements_set has a matching element in lock_requirements_set. This combined check ensures the sets are equal, not just that one is a subset of the other.
Consider updating the comment to accurately describe the logic, for example: "For backward compatibility, we ensure sets equality by verifying the sets have the same size and every requirement in one set has a matching element in the other set."
| For backward compatibility, we ensure sets equality by checking the | |
| size of sets and set A is a subset of set B. | |
| For backward compatibility, we ensure the two requirement sets are equal | |
| by verifying they have the same size and that every requirement in one | |
| set has a matching requirement in the other set. |
|
Just noticed the pypa/packaging has released https://github.com/pypa/packaging/releases/tag/26.0 with the upstream fix pypa/packaging#1022 We can revert #100 with that new version of packaging, but need to have #101 anyway. |
|
🎉 This PR is included in version 1.11.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
which resolves #99
Note: this can potentially be reverted depending on how pypa/packaging#1018 will be resolved.