Remove ResolutionGraph#requirements (#903)

This commit is contained in:
Charlie Marsh 2024-01-12 15:09:19 -05:00 committed by GitHub
parent d3f65c317d
commit 477186dcb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View file

@ -9,7 +9,7 @@ use fs_err::File;
use itertools::Itertools;
use petgraph::dot::{Config as DotConfig, Dot};
use distribution_types::IndexUrls;
use distribution_types::{IndexUrls, Resolution};
use pep508_rs::Requirement;
use platform_host::Platform;
use puffin_cache::{Cache, CacheArgs};
@ -97,16 +97,15 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
write!(&mut writer, "{graphviz:?}")?;
}
let mut resolution = resolution_graph.requirements();
resolution.sort_unstable_by(|a, b| a.name.cmp(&b.name));
let requirements = Resolution::from(resolution_graph).requirements();
#[allow(clippy::print_stderr, clippy::ignored_unit_patterns)]
#[allow(clippy::print_stderr)]
match args.format {
ResolveCliFormat::Compact => {
println!("{}", resolution.iter().map(ToString::to_string).join(" "));
println!("{}", requirements.iter().map(ToString::to_string).join(" "));
}
ResolveCliFormat::Expanded => {
for package in resolution {
for package in requirements {
println!("{}", package);
}
}

View file

@ -12,7 +12,7 @@ use url::Url;
use distribution_types::{Dist, DistributionMetadata, LocalEditable, Name, PackageId, Verbatim};
use pep440_rs::Version;
use pep508_rs::{Requirement, VerbatimUrl};
use pep508_rs::VerbatimUrl;
use puffin_normalize::{ExtraName, PackageName};
use puffin_traits::OnceMap;
use pypi_types::{Hashes, Metadata21};
@ -201,16 +201,6 @@ impl ResolutionGraph {
self.petgraph.node_count() == 0
}
/// Return the set of [`Requirement`]s that this graph represents.
pub fn requirements(&self) -> Vec<Requirement> {
self.petgraph
.node_indices()
.map(|node| &self.petgraph[node])
.cloned()
.map(Requirement::from)
.collect()
}
/// Return the [`Diagnostic`]s that were encountered while building the graph.
pub fn diagnostics(&self) -> &[Diagnostic] {
&self.diagnostics