Skip to content

🐛 fix requirements equality check in newer version of hatch#100

Merged
juftin merged 3 commits intojuftin:mainfrom
Bluefissure:fix/dependencies-compare-requirements
Jan 2, 2026
Merged

🐛 fix requirements equality check in newer version of hatch#100
juftin merged 3 commits intojuftin:mainfrom
Bluefissure:fix/dependencies-compare-requirements

Conversation

@Bluefissure
Copy link
Contributor

which resolves #99

Note: this can potentially be reverted depending on how pypa/packaging#1018 will be resolved.

@Bluefissure
Copy link
Contributor Author

Bluefissure commented Dec 30, 2025

Looks like pypa/packaging#1022 is fixing the subclassing issue, will cancel this PR if that gets merged in it might take a while to wait for a new packaging release with the fix, we can still benefit from this temp fix before that.

Copy link

Copilot AI left a 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 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_requirements method 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.

Comment on lines +133 to +134
For backward compatibility, we ensure sets equality by checking the
size of sets and set A is a subset of set B.
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

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."

Suggested change
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.

Copilot uses AI. Check for mistakes.
@juftin juftin merged commit 475f0cc into juftin:main Jan 2, 2026
2 checks passed
@Bluefissure Bluefissure deleted the fix/dependencies-compare-requirements branch January 2, 2026 03:29
@Bluefissure
Copy link
Contributor Author

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.

github-actions bot added a commit that referenced this pull request Jan 28, 2026
# [v1.11.6](v1.11.5...v1.11.6) (2026-01-28)

## 🐛 Bug Fixes
- [`475f0cc`](475f0cc)  fix requirements equality check in newer version of hatch (#100) (Issues: [`#100`](#100) [`#99`](#99))

[skip ci]
@juftin
Copy link
Owner

juftin commented Jan 28, 2026

🎉 This PR is included in version 1.11.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compare_requirements does not detect equal requirements

3 participants