uv/crates/uv-resolver
Zanie Blue 0efdbcc95b
Improve display of available package ranges (#6118)
Includes the changes from https://github.com/astral-sh/uv/pull/6071 but
takes them way further.

When we have the set of available versions for a package, we can do a
much better job displaying an error.

For example:

```
❯ uv add 'httpx>999,<9999'
  × No solution found when resolving dependencies:
  ╰─▶ Because only the following versions of httpx are available:
          httpx<=999
          httpx>=9999
      and example==0.1.0 depends on httpx>999,<9999, we can conclude that example==0.1.0 cannot be used.
      And because only example==0.1.0 is available and you require example, we can conclude that the requirements are unsatisfiable.
```

The resolver has demonstrated that the requested range cannot be used
because there are only versions in ranges _outside_ the requested range.
However, the display of the range of available versions is pretty bad!
We say there are versions of httpx available in ranges that definitely
have no versions available.

With this pull request, the error becomes:

```
❯ uv add 'httpx>999,<9999'
  × No solution found when resolving dependencies:
  ╰─▶ Because only httpx<=1.0.0b0 is available and example depends on httpx>999,<9999, we can conclude that example's
      requirements are unsatisfiable.
      And because your workspace requires example, we can conclude that your workspace's requirements are unsatisfiable.
```

We achieve this by:

1. Dropping ranges disjoint with the range of available versions, e.g.,
this removes `httpx>=9999`
2. Replacing ranges that capture the _entire_ range of available
versions with the smaller range, e.g., this replaces `httpx<=999` with
`<=1.0.0b0`.

~Note that when we perform (2), we may include an additional bound that
is not relevant, e.g., we include the lower bound of `>=0.6.7`. This is
a bit extraneous, but I don't think it's confusing. We can consider some
advanced logic to avoid that later.~ (edit: I did this, it wasn't hard)

We also improve error messages when there is _only_ one version
available by showing that version instead of a range.
2024-08-15 17:28:45 +00:00
..
src Improve display of available package ranges (#6118) 2024-08-15 17:28:45 +00:00
Cargo.toml Implement marker trees using algebraic decision diagrams (#5898) 2024-08-09 13:40:02 -04:00