Use shortened anyhow::Result everywhere (#457)

This commit is contained in:
Charlie Marsh 2023-11-19 11:26:21 -08:00 committed by GitHub
parent 380030bb5c
commit 3df3110800
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -3,7 +3,7 @@ use std::io::{BufWriter, Write};
use std::path::PathBuf;
use anstream::println;
use anyhow::Context;
use anyhow::{Context, Result};
use clap::{Parser, ValueEnum};
use fs_err::File;
use itertools::Itertools;
@ -41,7 +41,7 @@ pub(crate) struct ResolveCliArgs {
cache_args: CacheArgs,
}
pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> anyhow::Result<()> {
pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
let cache_dir = CacheDir::try_from(args.cache_args)?;
let platform = Platform::current()?;

View file

@ -42,9 +42,9 @@ pub(crate) async fn resolve_many(args: ResolveManyArgs) -> Result<()> {
let data = fs::read_to_string(&args.list)?;
let lines = data.lines().map(Requirement::from_str);
let requirements: Vec<Requirement> = if let Some(limit) = args.limit {
lines.take(limit).collect::<anyhow::Result<_, _>>()?
lines.take(limit).collect::<Result<_, _>>()?
} else {
lines.collect::<anyhow::Result<_, _>>()?
lines.collect::<Result<_, _>>()?
};
let platform = Platform::current()?;

View file

@ -4,6 +4,8 @@ use std::future::Future;
use std::path::Path;
use std::pin::Pin;
use anyhow::Result;
use pep508_rs::Requirement;
use puffin_interpreter::{InterpreterInfo, Virtualenv};
@ -68,7 +70,7 @@ pub trait BuildContext {
fn resolve<'a>(
&'a self,
requirements: &'a [Requirement],
) -> Pin<Box<dyn Future<Output = anyhow::Result<Vec<Requirement>>> + Send + 'a>>;
) -> Pin<Box<dyn Future<Output = Result<Vec<Requirement>>> + Send + 'a>>;
/// Install the given set of package versions into the virtual environment. The environment must
/// use the same base python as [`BuildContext::base_python`]
@ -76,7 +78,7 @@ pub trait BuildContext {
&'a self,
requirements: &'a [Requirement],
venv: &'a Virtualenv,
) -> Pin<Box<dyn Future<Output = anyhow::Result<()>> + Send + 'a>>;
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
/// Build a source distribution into a wheel from an archive.
///
@ -89,5 +91,5 @@ pub trait BuildContext {
subdirectory: Option<&'a Path>,
wheel_dir: &'a Path,
package_id: &'a str,
) -> Pin<Box<dyn Future<Output = anyhow::Result<String>> + Send + 'a>>;
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'a>>;
}