Skip to content

Fall back to distributions without hashes in resolver - #2949

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/check-hashes-v
Apr 10, 2024
Merged

charliermarsh merged 1 commit into
mainfrom
charlie/check-hashes-v

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Apr 9, 2024 •

Copy link
Copy Markdown
Member

Summary

This represents a change to --require-hashes in the event that we don't find a matching hash from the registry. The behavior in this PR is closer to pip's.

Prior to this PR, if a distribution had no reported hash, or only mismatched hashes, we would mark it as incompatible. Now, we mark it as compatible, but we use the hash-agreement as part of the ordering, such that we prefer any distribution with a matching hash, then any distribution with no hash, then any distribution with a mismatched hash.

As a result, if an index reports incorrect hashes, but the user provides the correct one, resolution now succeeds, where it would've failed.

Similarly, if an index omits hashes altogether, but the user provides the correct one, resolution now succeeds, where it would've failed.

If we end up picking a distribution whose hash ultimately doesn't match, we'll reject it later, after resolution.

@charliermarsh charliermarsh added the enhancement New feature or improvement to existing functionality label Apr 9, 2024
@charliermarsh
charliermarsh marked this pull request as ready for review April 9, 2024 23:12
@charliermarsh
charliermarsh requested a review from zanieb April 9, 2024 23:13
Comment thread crates/uv/tests/pip_sync.rs Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These aren't as nice-looking, but keep in mind that for --require-hashes, the user has to pin all dependencies upfront anyway. There's no backtracking or anything.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

They're pretty ugly but 🤷‍♂️ we could address later if we want.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Absolutely DESTROYING my error messages

@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-iii branch from f66887c to cdb2449 Compare April 9, 2024 23:18
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-v branch from 19505ca to 6f897d2 Compare April 9, 2024 23:19
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-iii branch from cdb2449 to 32a2088 Compare April 9, 2024 23:24
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-v branch from 6f897d2 to fc6c30c Compare April 9, 2024 23:25
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-iii branch from 32a2088 to d8f5d37 Compare April 9, 2024 23:56
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-v branch from fc6c30c to fdd87aa Compare April 9, 2024 23:56

@zanieb zanieb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah this UX seems much better.

@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-iii branch 2 times, most recently from 669384d to e3f5242 Compare April 10, 2024 18:55
Base automatically changed from charlie/check-hashes-iii to main April 10, 2024 19:09
@charliermarsh
charliermarsh force-pushed the charlie/check-hashes-v branch from fdd87aa to d3b6023 Compare April 10, 2024 19:13
@charliermarsh
charliermarsh enabled auto-merge (squash) April 10, 2024 19:14
@charliermarsh
charliermarsh merged commit c18551f into main Apr 10, 2024
@charliermarsh
charliermarsh deleted the charlie/check-hashes-v branch April 10, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants