Improve error messaging when a dependency is not found (#1241)

Previously, whenever we encountered a missing package we would throw an
error without information about why the package was requested. This
meant that if a transitive dependency required a missing package, the
user would have no idea why it was even selected. Here, we track
`NotFound` and `NoIndex` errors as `NoVersions` incompatibilities with
an attached reason. Improves our test coverage for `--no-index` without
`--find-links`.

The
[snapshots](https://github.com/astral-sh/puffin/pull/1241/files#diff-3eea1658f165476252f1f061d0aa9f915aabdceafac21611cdf45019447f60ec)
show a nice improvement.

I think this will also enable backtracking to another version if some
version of transitive dependency has a missing dependency. I'll write a
scenario for that next.

Requires https://github.com/zanieb/pubgrub/pull/22
This commit is contained in:
Zanie Blue 2024-02-05 08:43:05 -06:00 committed by GitHub
parent be9125b0f0
commit d090acf13d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 351 additions and 74 deletions

View file

@ -6,14 +6,14 @@ use once_map::OnceMap;
use puffin_normalize::PackageName;
use pypi_types::Metadata21;
use crate::version_map::VersionMap;
use super::provider::VersionsResponse;
/// In-memory index of package metadata.
#[derive(Default)]
pub struct InMemoryIndex {
/// A map from package name to the metadata for that package and the index where the metadata
/// came from.
pub(crate) packages: OnceMap<PackageName, VersionMap>,
pub(crate) packages: OnceMap<PackageName, VersionsResponse>,
/// A map from package ID to metadata for that distribution.
pub(crate) distributions: OnceMap<PackageId, Metadata21>,