Skip to content
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

Use impl IntoIterator to avoid clones #24

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Use impl IntoIterator to avoid clones #24

merged 1 commit into from
Feb 22, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Feb 21, 2024

Reviving Jacob's PR to see if we can improve our error messages for conflicting dependencies within a single package.

@charliermarsh
Copy link
Member Author

\cc @zanieb for visibility.

src/lib.rs Outdated
//! unimplemented!();
//! Ok(Dependencies::Available([]))
Copy link
Member

Choose a reason for hiding this comment

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

?

Comment on lines -170 to 175
Dependencies::Available(x) if x.contains_key(p) => {
Dependencies::Available(x) if x.clone().into_iter().any(|(d, _)| &d == p) => {
return Err(PubGrubError::SelfDependency {
package: p.clone(),
version: v,
version: v.clone(),
});
}
Copy link
Member

Choose a reason for hiding this comment

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

Are any of these new clones problematic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not for us, because we already use a vector here IIUC.

@charliermarsh charliermarsh merged commit aab132a into main Feb 22, 2024
5 checks passed
@charliermarsh charliermarsh deleted the charlie/into branch February 22, 2024 02:00
charliermarsh added a commit to astral-sh/uv that referenced this pull request Feb 22, 2024
## Summary

This revives a PR from long ago
(#383 and
astral-sh/pubgrub#24) that modifies how we deal
with dependencies that are declared multiple times within a single
package.

To quote from the originating PR:

> Uses an experimental pubgrub branch (#370) that allows us to handle
multiple version ranges for a single dependency to the solver which
results in better error messages because the derivation tree contains
all of the relevant versions. Previously, the version ranges were merged
(by us) in the resolver before handing them to pubgrub since only one
range could be provided per package. Since we don't merge the versions
anymore, we no longer give the solver an empty range for conflicting
requirements; instead the solver comes to that conclusion from the
provided versions. You can see the improved error message for direct
dependencies in [this
snapshot](https://github.com/astral-sh/puffin/pull/383/files#diff-a0437f2c20cde5e2f15199a3bf81a102b92580063268417847ec9c793a115bd0).

The main issue with that PR was around its handling of URL dependencies,
so this PR _also_ refactors how we handle those. Previously, we stored
URL dependencies on `PubGrubPackage`, but they were omitted from the
hash and equality implementations of `PubGrubPackage`. This led to some
really careful codepaths wherein we had to ensure that we always visited
URLs before non-URL packages, so that the URL-inclusive versions were
included in any hashmaps, etc. I considered preserving this approach,
but it would require us to rely on lots of internal details of PubGrub
(since we'd now be relying on PubGrub to merge those packages in the
"right" order).

So, instead, we now _always_ set the URL on a given package, whenever
that package was _given_ a URL upfront. I think this is easier to reason
about: if the user provided a URL for `flask`, then we should just
always add the URL for `flask`. If we see some other URL for `flask`, we
error, like before. If we see some unknown URL for `flask`, we error,
like before.

Closes #1522.

Closes #1821.

Closes #1615.
konstin pushed a commit that referenced this pull request Mar 6, 2024
konstin pushed a commit that referenced this pull request Mar 12, 2024
konstin pushed a commit that referenced this pull request Mar 12, 2024
konstin pushed a commit that referenced this pull request Mar 13, 2024
konstin pushed a commit that referenced this pull request Mar 22, 2024
konstin pushed a commit that referenced this pull request May 2, 2024
konstin pushed a commit that referenced this pull request May 7, 2024
konstin pushed a commit that referenced this pull request May 8, 2024
konstin pushed a commit that referenced this pull request May 21, 2024
konstin pushed a commit that referenced this pull request Jun 1, 2024
konstin pushed a commit that referenced this pull request Jun 1, 2024
konstin pushed a commit that referenced this pull request Jun 1, 2024
konstin pushed a commit that referenced this pull request Jun 3, 2024
konstin pushed a commit that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants