diff --git a/Cargo.toml b/Cargo.toml index d0f7d769c..cc6e4a7b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ exclude = [ resolver = "2" [workspace.package] -edition = "2021" -rust-version = "1.84" +edition = "2024" +rust-version = "1.85" homepage = "https://pypi.org/project/uv/" documentation = "https://pypi.org/project/uv/" repository = "https://github.com/astral-sh/uv" diff --git a/crates/uv-auth/Cargo.toml b/crates/uv-auth/Cargo.toml index f9df90e92..2717254d9 100644 --- a/crates/uv-auth/Cargo.toml +++ b/crates/uv-auth/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-auth" version = "0.0.1" -edition = "2021" +edition = { workspace = true } [lib] doctest = false diff --git a/crates/uv-auth/src/cache.rs b/crates/uv-auth/src/cache.rs index d61a6b880..5c57c8c18 100644 --- a/crates/uv-auth/src/cache.rs +++ b/crates/uv-auth/src/cache.rs @@ -10,8 +10,8 @@ use url::Url; use uv_once_map::OnceMap; -use crate::credentials::{Credentials, Username}; use crate::Realm; +use crate::credentials::{Credentials, Username}; type FxOnceMap = OnceMap>; diff --git a/crates/uv-auth/src/credentials.rs b/crates/uv-auth/src/credentials.rs index 6c5bb74f7..ed27334f1 100644 --- a/crates/uv-auth/src/credentials.rs +++ b/crates/uv-auth/src/credentials.rs @@ -5,8 +5,8 @@ use std::borrow::Cow; use std::fmt; use netrc::Netrc; -use reqwest::header::HeaderValue; use reqwest::Request; +use reqwest::header::HeaderValue; use std::io::Read; use std::io::Write; use url::Url; diff --git a/crates/uv-auth/src/middleware.rs b/crates/uv-auth/src/middleware.rs index 86155438d..f31a01540 100644 --- a/crates/uv-auth/src/middleware.rs +++ b/crates/uv-auth/src/middleware.rs @@ -4,11 +4,11 @@ use http::{Extensions, StatusCode}; use url::Url; use crate::{ + CREDENTIALS_CACHE, CredentialsCache, KeyringProvider, cache::FetchUrl, credentials::{Credentials, Username}, index::{AuthPolicy, Indexes}, realm::Realm, - CredentialsCache, KeyringProvider, CREDENTIALS_CACHE, }; use anyhow::{anyhow, format_err}; use netrc::Netrc; @@ -591,8 +591,8 @@ mod tests { use wiremock::matchers::{basic_auth, method, path_regex}; use wiremock::{Mock, MockServer, ResponseTemplate}; - use crate::credentials::Password; use crate::Index; + use crate::credentials::Password; use super::*; @@ -1097,7 +1097,10 @@ mod tests { let mut url = base_url.clone(); url.set_username("other_user").unwrap(); assert!( - matches!(client.get(url).send().await, Err(reqwest_middleware::Error::Middleware(_))), + matches!( + client.get(url).send().await, + Err(reqwest_middleware::Error::Middleware(_)) + ), "If the username does not match, a password should not be fetched, and the middleware should fail eagerly since `authenticate = always` is not satisfied" ); @@ -1614,8 +1617,8 @@ mod tests { /// credentials for _every_ request URL at the cost of inconsistent behavior when /// credentials are not scoped to a realm. #[test(tokio::test)] - async fn test_credentials_from_keyring_mixed_authentication_in_realm_same_username( - ) -> Result<(), Error> { + async fn test_credentials_from_keyring_mixed_authentication_in_realm_same_username() + -> Result<(), Error> { let username = "user"; let password_1 = "password1"; let password_2 = "password2"; @@ -1714,8 +1717,8 @@ mod tests { /// where multiple URLs with the same username and realm share the same realm-level /// credentials cache entry. #[test(tokio::test)] - async fn test_credentials_from_keyring_mixed_authentication_different_indexes_same_realm( - ) -> Result<(), Error> { + async fn test_credentials_from_keyring_mixed_authentication_different_indexes_same_realm() + -> Result<(), Error> { let username = "user"; let password_1 = "password1"; let password_2 = "password2"; @@ -1826,8 +1829,8 @@ mod tests { /// Demonstrates that when an index' credentials are cached for its realm, we /// find those credentials if they're not present in the keyring. #[test(tokio::test)] - async fn test_credentials_from_keyring_shared_authentication_different_indexes_same_realm( - ) -> Result<(), Error> { + async fn test_credentials_from_keyring_shared_authentication_different_indexes_same_realm() + -> Result<(), Error> { let username = "user"; let password = "password"; diff --git a/crates/uv-bench/benches/distribution_filename.rs b/crates/uv-bench/benches/distribution_filename.rs index 6f6a3e68e..99d72cf05 100644 --- a/crates/uv-bench/benches/distribution_filename.rs +++ b/crates/uv-bench/benches/distribution_filename.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use uv_bench::criterion::{ - criterion_group, criterion_main, measurement::WallTime, BenchmarkId, Criterion, Throughput, + BenchmarkId, Criterion, Throughput, criterion_group, criterion_main, measurement::WallTime, }; use uv_distribution_filename::WheelFilename; use uv_platform_tags::{AbiTag, LanguageTag, PlatformTag, Tags}; diff --git a/crates/uv-bench/benches/uv.rs b/crates/uv-bench/benches/uv.rs index 095f150cd..03a360ad5 100644 --- a/crates/uv-bench/benches/uv.rs +++ b/crates/uv-bench/benches/uv.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use uv_bench::criterion::black_box; -use uv_bench::criterion::{criterion_group, criterion_main, measurement::WallTime, Criterion}; +use uv_bench::criterion::{Criterion, criterion_group, criterion_main, measurement::WallTime}; use uv_cache::Cache; use uv_client::RegistryClientBuilder; use uv_distribution_types::Requirement; diff --git a/crates/uv-build-backend/src/lib.rs b/crates/uv-build-backend/src/lib.rs index ddc59eda6..c193f3a0a 100644 --- a/crates/uv-build-backend/src/lib.rs +++ b/crates/uv-build-backend/src/lib.rs @@ -4,7 +4,7 @@ mod settings; mod source_dist; mod wheel; -pub use metadata::{check_direct_build, PyProjectToml}; +pub use metadata::{PyProjectToml, check_direct_build}; pub use settings::{BuildBackendSettings, WheelDataIncludes}; pub use source_dist::{build_source_dist, list_source_dist}; pub use wheel::{build_editable, build_wheel, list_wheel, metadata}; diff --git a/crates/uv-build-backend/src/source_dist.rs b/crates/uv-build-backend/src/source_dist.rs index 9cc890a8a..c39a27e44 100644 --- a/crates/uv-build-backend/src/source_dist.rs +++ b/crates/uv-build-backend/src/source_dist.rs @@ -1,10 +1,10 @@ use crate::metadata::DEFAULT_EXCLUDES; use crate::wheel::build_exclude_matcher; use crate::{ - find_roots, BuildBackendSettings, DirectoryWriter, Error, FileList, ListWriter, PyProjectToml, + BuildBackendSettings, DirectoryWriter, Error, FileList, ListWriter, PyProjectToml, find_roots, }; -use flate2::write::GzEncoder; use flate2::Compression; +use flate2::write::GzEncoder; use fs_err::File; use globset::{Glob, GlobSet}; use std::io; diff --git a/crates/uv-build-backend/src/wheel.rs b/crates/uv-build-backend/src/wheel.rs index cf007c9c5..69af1e203 100644 --- a/crates/uv-build-backend/src/wheel.rs +++ b/crates/uv-build-backend/src/wheel.rs @@ -17,8 +17,8 @@ use uv_warnings::warn_user_once; use crate::metadata::DEFAULT_EXCLUDES; use crate::{ - find_module_root, find_roots, BuildBackendSettings, DirectoryWriter, Error, FileList, - ListWriter, PyProjectToml, + BuildBackendSettings, DirectoryWriter, Error, FileList, ListWriter, PyProjectToml, + find_module_root, find_roots, }; /// Build a wheel from the source tree and place it in the output directory. diff --git a/crates/uv-build-frontend/src/lib.rs b/crates/uv-build-frontend/src/lib.rs index a74b1ce38..1c29b2c31 100644 --- a/crates/uv-build-frontend/src/lib.rs +++ b/crates/uv-build-frontend/src/lib.rs @@ -19,13 +19,13 @@ use fs_err as fs; use indoc::formatdoc; use itertools::Itertools; use rustc_hash::FxHashMap; -use serde::de::{value, IntoDeserializer, SeqAccess, Visitor}; -use serde::{de, Deserialize, Deserializer}; +use serde::de::{IntoDeserializer, SeqAccess, Visitor, value}; +use serde::{Deserialize, Deserializer, de}; use tempfile::TempDir; use tokio::io::AsyncBufReadExt; use tokio::process::Command; use tokio::sync::{Mutex, Semaphore}; -use tracing::{debug, info_span, instrument, Instrument}; +use tracing::{Instrument, debug, info_span, instrument}; use uv_configuration::{BuildKind, BuildOutput, ConfigSettings, SourceStrategy}; use uv_distribution::BuildRequires; diff --git a/crates/uv-build/src/main.rs b/crates/uv-build/src/main.rs index ef8ff18b8..4b9b5b3ee 100644 --- a/crates/uv-build/src/main.rs +++ b/crates/uv-build/src/main.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use std::env; use std::io::Write; use std::path::PathBuf; diff --git a/crates/uv-cache-key/src/cache_key.rs b/crates/uv-cache-key/src/cache_key.rs index 019c54eb5..d85862123 100644 --- a/crates/uv-cache-key/src/cache_key.rs +++ b/crates/uv-cache-key/src/cache_key.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; use std::hash::{Hash, Hasher}; use std::num::{ - NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroU128, NonZeroU16, - NonZeroU32, NonZeroU64, NonZeroU8, + NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroU8, NonZeroU16, NonZeroU32, + NonZeroU64, NonZeroU128, }; use std::path::{Path, PathBuf}; diff --git a/crates/uv-cache/src/lib.rs b/crates/uv-cache/src/lib.rs index e05b3c7ed..18407a2b6 100644 --- a/crates/uv-cache/src/lib.rs +++ b/crates/uv-cache/src/lib.rs @@ -11,7 +11,7 @@ use tracing::debug; pub use archive::ArchiveId; use uv_cache_info::Timestamp; -use uv_fs::{cachedir, directories, LockedFile}; +use uv_fs::{LockedFile, cachedir, directories}; use uv_normalize::PackageName; use uv_pypi_types::ResolutionMetadata; @@ -19,7 +19,7 @@ pub use crate::by_timestamp::CachedByTimestamp; #[cfg(feature = "clap")] pub use crate::cli::CacheArgs; use crate::removal::Remover; -pub use crate::removal::{rm_rf, Removal}; +pub use crate::removal::{Removal, rm_rf}; pub use crate::wheel::WheelCache; use crate::wheel::WheelCacheKind; @@ -1194,11 +1194,7 @@ impl Refresh { pub fn combine(self, other: Refresh) -> Self { /// Return the maximum of two timestamps. fn max(a: Timestamp, b: Timestamp) -> Timestamp { - if a > b { - a - } else { - b - } + if a > b { a } else { b } } match (self, other) { diff --git a/crates/uv-cache/src/wheel.rs b/crates/uv-cache/src/wheel.rs index ab074df06..d00a2895c 100644 --- a/crates/uv-cache/src/wheel.rs +++ b/crates/uv-cache/src/wheel.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use url::Url; -use uv_cache_key::{cache_digest, CanonicalUrl}; +use uv_cache_key::{CanonicalUrl, cache_digest}; use uv_distribution_types::IndexUrl; /// Cache wheels and their metadata, both from remote wheels and built from source distributions. diff --git a/crates/uv-cli/src/compat.rs b/crates/uv-cli/src/compat.rs index fca35fd44..50f4c173d 100644 --- a/crates/uv-cli/src/compat.rs +++ b/crates/uv-cli/src/compat.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use clap::{Args, ValueEnum}; use uv_warnings::warn_user; diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 94df91740..039d9ccf0 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -3,9 +3,9 @@ use std::ops::{Deref, DerefMut}; use std::path::PathBuf; use std::str::FromStr; -use anyhow::{anyhow, Result}; -use clap::builder::styling::{AnsiColor, Effects, Style}; +use anyhow::{Result, anyhow}; use clap::builder::Styles; +use clap::builder::styling::{AnsiColor, Effects, Style}; use clap::{Args, Parser, Subcommand}; use url::Url; diff --git a/crates/uv-cli/src/version.rs b/crates/uv-cli/src/version.rs index ee4dd43e4..296f9f54c 100644 --- a/crates/uv-cli/src/version.rs +++ b/crates/uv-cli/src/version.rs @@ -3,7 +3,7 @@ use std::fmt; use serde::Serialize; -use uv_pep508::{uv_pep440::Version, PackageName}; +use uv_pep508::{PackageName, uv_pep440::Version}; /// Information about the git repository where uv was built from. #[derive(Serialize)] diff --git a/crates/uv-client/Cargo.toml b/crates/uv-client/Cargo.toml index e86ab2084..81d1909fe 100644 --- a/crates/uv-client/Cargo.toml +++ b/crates/uv-client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-client" version = "0.0.1" -edition = "2021" +edition = { workspace = true } [lib] doctest = false diff --git a/crates/uv-client/src/base_client.rs b/crates/uv-client/src/base_client.rs index d32a0f5d3..2db0a920e 100644 --- a/crates/uv-client/src/base_client.rs +++ b/crates/uv-client/src/base_client.rs @@ -25,10 +25,10 @@ use uv_static::EnvVars; use uv_version::version; use uv_warnings::warn_user_once; +use crate::Connectivity; use crate::linehaul::LineHaul; use crate::middleware::OfflineMiddleware; use crate::tls::read_identity; -use crate::Connectivity; pub const DEFAULT_RETRIES: u32 = 3; diff --git a/crates/uv-client/src/cached_client.rs b/crates/uv-client/src/cached_client.rs index e23b39415..b9327fa21 100644 --- a/crates/uv-client/src/cached_client.rs +++ b/crates/uv-client/src/cached_client.rs @@ -8,17 +8,17 @@ use reqwest_retry::RetryPolicy; use rkyv::util::AlignedVec; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use tracing::{debug, info_span, instrument, trace, warn, Instrument}; +use tracing::{Instrument, debug, info_span, instrument, trace, warn}; use uv_cache::{CacheEntry, Freshness}; use uv_fs::write_atomic; -use crate::base_client::is_extended_transient_error; use crate::BaseClient; +use crate::base_client::is_extended_transient_error; use crate::{ + Error, ErrorKind, httpcache::{AfterResponse, BeforeRequest, CachePolicy, CachePolicyBuilder}, rkyvutil::OwnedArchive, - Error, ErrorKind, }; /// A trait the generalizes (de)serialization at a high level. @@ -230,7 +230,7 @@ impl CachedClient { CallbackReturn: Future>, { let payload = self - .get_cacheable(req, cache_entry, cache_control, |resp| async { + .get_cacheable(req, cache_entry, cache_control, async |resp| { let payload = response_callback(resp).await?; Ok(SerdeCacheable { inner: payload }) }) @@ -359,7 +359,7 @@ impl CachedClient { let (response, cache_policy) = self.fresh_request(req).await?; let payload = self - .run_response_callback(cache_entry, cache_policy, response, move |resp| async { + .run_response_callback(cache_entry, cache_policy, response, async |resp| { let payload = response_callback(resp).await?; Ok(SerdeCacheable { inner: payload }) }) @@ -585,7 +585,7 @@ impl CachedClient { CallbackReturn: Future>, { let payload = self - .get_cacheable_with_retry(req, cache_entry, cache_control, |resp| async { + .get_cacheable_with_retry(req, cache_entry, cache_control, async |resp| { let payload = response_callback(resp).await?; Ok(SerdeCacheable { inner: payload }) }) diff --git a/crates/uv-client/src/error.rs b/crates/uv-client/src/error.rs index ca7faebaa..ad1e06823 100644 --- a/crates/uv-client/src/error.rs +++ b/crates/uv-client/src/error.rs @@ -10,7 +10,7 @@ use uv_normalize::PackageName; use uv_redacted::redacted_url; use crate::middleware::OfflineError; -use crate::{html, FlatIndexError}; +use crate::{FlatIndexError, html}; #[derive(Debug, thiserror::Error)] #[error(transparent)] @@ -46,7 +46,7 @@ impl Error { /// Returns `true` if this error corresponds to an I/O "not found" error. pub(crate) fn is_file_not_exists(&self) -> bool { - let ErrorKind::Io(ref err) = &*self.kind else { + let ErrorKind::Io(err) = &*self.kind else { return false; }; matches!(err.kind(), std::io::ErrorKind::NotFound) @@ -246,7 +246,9 @@ pub enum ErrorKind { #[error("Writing to cache archive failed: {0}")] ArchiveWrite(String), - #[error("Network connectivity is disabled, but the requested data wasn't found in the cache for: `{0}`")] + #[error( + "Network connectivity is disabled, but the requested data wasn't found in the cache for: `{0}`" + )] Offline(String), } diff --git a/crates/uv-client/src/flat_index.rs b/crates/uv-client/src/flat_index.rs index 93987be41..ca2166e18 100644 --- a/crates/uv-client/src/flat_index.rs +++ b/crates/uv-client/src/flat_index.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use futures::{FutureExt, StreamExt}; use reqwest::Response; -use tracing::{debug, info_span, warn, Instrument}; +use tracing::{Instrument, debug, info_span, warn}; use url::Url; use uv_cache::{Cache, CacheBucket}; @@ -113,7 +113,7 @@ impl<'a> FlatIndexClient<'a> { indexes: impl Iterator, ) -> Result { let mut fetches = futures::stream::iter(indexes) - .map(|index| async move { + .map(async |index| { let entries = self.fetch_index(index).await?; if entries.is_empty() { warn!("No packages found in `--find-links` entry: {}", index); diff --git a/crates/uv-client/src/lib.rs b/crates/uv-client/src/lib.rs index 49ee1d955..3ea33204c 100644 --- a/crates/uv-client/src/lib.rs +++ b/crates/uv-client/src/lib.rs @@ -1,6 +1,6 @@ pub use base_client::{ - is_extended_transient_error, AuthIntegration, BaseClient, BaseClientBuilder, ExtraMiddleware, - UvRetryableStrategy, DEFAULT_RETRIES, + AuthIntegration, BaseClient, BaseClientBuilder, DEFAULT_RETRIES, ExtraMiddleware, + UvRetryableStrategy, is_extended_transient_error, }; pub use cached_client::{CacheControl, CachedClient, CachedClientError, DataWithCachePolicy}; pub use error::{Error, ErrorKind, WrappedReqwestError}; diff --git a/crates/uv-client/src/middleware.rs b/crates/uv-client/src/middleware.rs index 5865ab2c2..13bd94904 100644 --- a/crates/uv-client/src/middleware.rs +++ b/crates/uv-client/src/middleware.rs @@ -20,7 +20,11 @@ impl OfflineError { impl std::fmt::Display for OfflineError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Network connectivity is disabled, but the requested data wasn't found in the cache for: `{}`", self.url) + write!( + f, + "Network connectivity is disabled, but the requested data wasn't found in the cache for: `{}`", + self.url + ) } } diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index f46b36fb4..9831fb81d 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -13,7 +13,7 @@ use reqwest::{Proxy, Response}; use reqwest_middleware::ClientWithMiddleware; use rustc_hash::FxHashMap; use tokio::sync::{Mutex, Semaphore}; -use tracing::{debug, info_span, instrument, trace, warn, Instrument}; +use tracing::{Instrument, debug, info_span, instrument, trace, warn}; use url::Url; use uv_auth::Indexes; @@ -352,7 +352,9 @@ impl RegistryClient { // The search failed because of an HTTP status code that we don't ignore for // this index. We end our search here. SimpleMetadataSearchOutcome::StatusCodeFailure(status_code) => { - debug!("Indexes search failed because of status code failure: {status_code}"); + debug!( + "Indexes search failed because of status code failure: {status_code}" + ); break; } } @@ -371,7 +373,7 @@ impl RegistryClient { // Otherwise, fetch concurrently. IndexStrategy::UnsafeBestMatch | IndexStrategy::UnsafeFirstMatch => { results = futures::stream::iter(indexes) - .map(|index| async move { + .map(async |index| { let _permit = download_concurrency.acquire().await; match index.format { IndexFormat::Simple => { @@ -400,12 +402,10 @@ impl RegistryClient { } }) .buffered(8) - .filter_map(|result: Result<_, Error>| async move { - match result { - Ok((index, Some(metadata))) => Some(Ok((index, metadata))), - Ok((_, None)) => None, - Err(err) => Some(Err(err)), - } + .filter_map(async |result: Result<_, Error>| match result { + Ok((index, Some(metadata))) => Some(Ok((index, metadata))), + Ok((_, None)) => None, + Err(err) => Some(Err(err)), }) .try_collect::>() .await?; @@ -800,7 +800,7 @@ impl RegistryClient { lock_entry.lock().await.map_err(ErrorKind::CacheWrite)? }; - let response_callback = |response: Response| async { + let response_callback = async |response: Response| { let bytes = response .bytes() .await @@ -987,11 +987,12 @@ impl RegistryClient { std::io::Error::new( std::io::ErrorKind::TimedOut, format!( - "Failed to download distribution due to network timeout. Try increasing UV_HTTP_TIMEOUT (current value: {}s).", self.timeout().as_secs() + "Failed to download distribution due to network timeout. Try increasing UV_HTTP_TIMEOUT (current value: {}s).", + self.timeout().as_secs() ), ) } else { - std::io::Error::new(std::io::ErrorKind::Other, err) + std::io::Error::other(err) } } } @@ -1224,7 +1225,7 @@ mod tests { use uv_normalize::PackageName; use uv_pypi_types::{JoinRelativeError, SimpleJson}; - use crate::{html::SimpleHtml, SimpleMetadata, SimpleMetadatum}; + use crate::{SimpleMetadata, SimpleMetadatum, html::SimpleHtml}; #[test] fn ignore_failing_files() { diff --git a/crates/uv-client/src/rkyvutil.rs b/crates/uv-client/src/rkyvutil.rs index 37ef9f5ff..fad4f0039 100644 --- a/crates/uv-client/src/rkyvutil.rs +++ b/crates/uv-client/src/rkyvutil.rs @@ -12,12 +12,12 @@ serializing and deserializing. */ use rkyv::{ + Archive, Deserialize, Portable, Serialize, api::high::{HighDeserializer, HighSerializer, HighValidator}, bytecheck::CheckBytes, rancor, ser::allocator::ArenaHandle, util::AlignedVec, - Archive, Deserialize, Portable, Serialize, }; use crate::{Error, ErrorKind}; diff --git a/crates/uv-configuration/src/config_settings.rs b/crates/uv-configuration/src/config_settings.rs index ed728d14c..cd1d67196 100644 --- a/crates/uv-configuration/src/config_settings.rs +++ b/crates/uv-configuration/src/config_settings.rs @@ -1,5 +1,5 @@ use std::{ - collections::{btree_map::Entry, BTreeMap}, + collections::{BTreeMap, btree_map::Entry}, str::FromStr, }; use uv_cache_key::CacheKeyHasher; diff --git a/crates/uv-configuration/src/dependency_groups.rs b/crates/uv-configuration/src/dependency_groups.rs index 1758aa448..345f4077c 100644 --- a/crates/uv-configuration/src/dependency_groups.rs +++ b/crates/uv-configuration/src/dependency_groups.rs @@ -1,6 +1,6 @@ use std::{borrow::Cow, sync::Arc}; -use uv_normalize::{DefaultGroups, GroupName, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, DefaultGroups, GroupName}; /// Manager of all dependency-group decisions and settings history. /// diff --git a/crates/uv-configuration/src/threading.rs b/crates/uv-configuration/src/threading.rs index ee11702b5..58b6190a6 100644 --- a/crates/uv-configuration/src/threading.rs +++ b/crates/uv-configuration/src/threading.rs @@ -1,7 +1,7 @@ //! Configure rayon and determine thread stack sizes. -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::LazyLock; +use std::sync::atomic::{AtomicUsize, Ordering}; use uv_static::EnvVars; /// The default minimum stack size for uv threads. diff --git a/crates/uv-console/Cargo.toml b/crates/uv-console/Cargo.toml index fcfb81dd4..c554304f5 100644 --- a/crates/uv-console/Cargo.toml +++ b/crates/uv-console/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-console" version = "0.0.1" -edition = "2021" +edition = { workspace = true } description = "Utilities for interacting with the terminal" [lib] diff --git a/crates/uv-console/src/lib.rs b/crates/uv-console/src/lib.rs index b31762fd1..807b77aa4 100644 --- a/crates/uv-console/src/lib.rs +++ b/crates/uv-console/src/lib.rs @@ -1,4 +1,4 @@ -use console::{measure_text_width, style, Key, Term}; +use console::{Key, Term, measure_text_width, style}; use std::{cmp::Ordering, iter}; /// Prompt the user for confirmation in the given [`Term`]. diff --git a/crates/uv-dev/src/generate_cli_reference.rs b/crates/uv-dev/src/generate_cli_reference.rs index 08a6091ba..7ae8ba9cb 100644 --- a/crates/uv-dev/src/generate_cli_reference.rs +++ b/crates/uv-dev/src/generate_cli_reference.rs @@ -3,13 +3,13 @@ use std::cmp::max; use std::path::PathBuf; use anstream::println; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::{Command, CommandFactory}; use itertools::Itertools; use pretty_assertions::StrComparison; -use crate::generate_all::Mode; use crate::ROOT_DIR; +use crate::generate_all::Mode; use uv_cli::Cli; @@ -353,7 +353,7 @@ mod tests { use crate::generate_all::Mode; - use super::{main, Args}; + use super::{Args, main}; #[test] fn test_generate_cli_reference() -> Result<()> { diff --git a/crates/uv-dev/src/generate_env_vars_reference.rs b/crates/uv-dev/src/generate_env_vars_reference.rs index 2ebcfd4d7..7265200c1 100644 --- a/crates/uv-dev/src/generate_env_vars_reference.rs +++ b/crates/uv-dev/src/generate_env_vars_reference.rs @@ -7,8 +7,8 @@ use std::path::PathBuf; use uv_static::EnvVars; -use crate::generate_all::Mode; use crate::ROOT_DIR; +use crate::generate_all::Mode; #[derive(clap::Args)] pub(crate) struct Args { @@ -113,7 +113,7 @@ mod tests { use crate::generate_all::Mode; - use super::{main, Args}; + use super::{Args, main}; #[test] fn test_generate_env_vars_reference() -> Result<()> { diff --git a/crates/uv-dev/src/generate_json_schema.rs b/crates/uv-dev/src/generate_json_schema.rs index dcead2785..75465f429 100644 --- a/crates/uv-dev/src/generate_json_schema.rs +++ b/crates/uv-dev/src/generate_json_schema.rs @@ -1,16 +1,16 @@ use std::path::PathBuf; use anstream::println; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use pretty_assertions::StrComparison; -use schemars::{schema_for, JsonSchema}; +use schemars::{JsonSchema, schema_for}; use serde::Deserialize; use uv_settings::Options as SettingsOptions; use uv_workspace::pyproject::ToolUv as WorkspaceOptions; -use crate::generate_all::Mode; use crate::ROOT_DIR; +use crate::generate_all::Mode; #[derive(Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] @@ -118,7 +118,7 @@ mod tests { use crate::generate_all::Mode; - use super::{main, Args}; + use super::{Args, main}; #[test] fn test_generate_json_schema() -> Result<()> { diff --git a/crates/uv-dev/src/generate_options_reference.rs b/crates/uv-dev/src/generate_options_reference.rs index 9c1310d12..3729f630a 100644 --- a/crates/uv-dev/src/generate_options_reference.rs +++ b/crates/uv-dev/src/generate_options_reference.rs @@ -5,7 +5,7 @@ use std::fmt::Write; use std::path::PathBuf; use anstream::println; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use itertools::Itertools; use pretty_assertions::StrComparison; use schemars::JsonSchema; @@ -16,8 +16,8 @@ use uv_options_metadata::{OptionField, OptionSet, OptionsMetadata, Visit}; use uv_settings::Options as SettingsOptions; use uv_workspace::pyproject::ToolUv as WorkspaceOptions; -use crate::generate_all::Mode; use crate::ROOT_DIR; +use crate::generate_all::Mode; #[derive(Deserialize, JsonSchema, OptionsMetadata)] #[serde(deny_unknown_fields)] @@ -398,7 +398,7 @@ mod tests { use crate::generate_all::Mode; - use super::{main, Args}; + use super::{Args, main}; #[test] fn test_generate_options_reference() -> Result<()> { diff --git a/crates/uv-dev/src/main.rs b/crates/uv-dev/src/main.rs index b83e4a5ca..e9825e134 100644 --- a/crates/uv-dev/src/main.rs +++ b/crates/uv-dev/src/main.rs @@ -7,8 +7,8 @@ use std::time::Instant; use anstream::eprintln; use owo_colors::OwoColorize; use tracing::debug; -use tracing_durations_export::plot::PlotConfig; use tracing_durations_export::DurationsLayerBuilder; +use tracing_durations_export::plot::PlotConfig; use tracing_subscriber::filter::Directive; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; diff --git a/crates/uv-dev/src/render_benchmarks.rs b/crates/uv-dev/src/render_benchmarks.rs index 3fdeb02a6..7f7d9218c 100644 --- a/crates/uv-dev/src/render_benchmarks.rs +++ b/crates/uv-dev/src/render_benchmarks.rs @@ -2,10 +2,10 @@ use std::path::{Path, PathBuf}; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use clap::Parser; use poloto::build; -use resvg::usvg_text_layout::{fontdb, TreeTextToPath}; +use resvg::usvg_text_layout::{TreeTextToPath, fontdb}; use serde::Deserialize; use tagu::prelude::*; diff --git a/crates/uv-dev/src/wheel_metadata.rs b/crates/uv-dev/src/wheel_metadata.rs index 9ef55dae1..312ced141 100644 --- a/crates/uv-dev/src/wheel_metadata.rs +++ b/crates/uv-dev/src/wheel_metadata.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use anstream::println; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use uv_cache::{Cache, CacheArgs}; diff --git a/crates/uv-dirs/src/lib.rs b/crates/uv-dirs/src/lib.rs index c5710b8a5..df3af9057 100644 --- a/crates/uv-dirs/src/lib.rs +++ b/crates/uv-dirs/src/lib.rs @@ -86,11 +86,7 @@ pub fn legacy_user_state_dir() -> Option { /// Return a [`PathBuf`] if the given [`OsString`] is an absolute path. fn parse_path(path: OsString) -> Option { let path = PathBuf::from(path); - if path.is_absolute() { - Some(path) - } else { - None - } + if path.is_absolute() { Some(path) } else { None } } /// Returns the path to the user configuration directory. diff --git a/crates/uv-distribution-filename/src/source_dist.rs b/crates/uv-distribution-filename/src/source_dist.rs index bbdf255e5..38cf632f6 100644 --- a/crates/uv-distribution-filename/src/source_dist.rs +++ b/crates/uv-distribution-filename/src/source_dist.rs @@ -226,11 +226,13 @@ mod tests { #[test] fn name_too_long() { - assert!(SourceDistFilename::parse( - "foo.zip", - SourceDistExtension::Zip, - &PackageName::from_str("foo-lib").unwrap() - ) - .is_err()); + assert!( + SourceDistFilename::parse( + "foo.zip", + SourceDistExtension::Zip, + &PackageName::from_str("foo-lib").unwrap() + ) + .is_err() + ); } } diff --git a/crates/uv-distribution-filename/src/wheel.rs b/crates/uv-distribution-filename/src/wheel.rs index 95ee8de93..d7dc7dfca 100644 --- a/crates/uv-distribution-filename/src/wheel.rs +++ b/crates/uv-distribution-filename/src/wheel.rs @@ -3,7 +3,7 @@ use std::hash::Hash; use std::str::FromStr; use memchr::memchr; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use thiserror::Error; use url::Url; diff --git a/crates/uv-distribution-types/src/cached.rs b/crates/uv-distribution-types/src/cached.rs index 06174e65a..84118ec49 100644 --- a/crates/uv-distribution-types/src/cached.rs +++ b/crates/uv-distribution-types/src/cached.rs @@ -12,6 +12,7 @@ use crate::{ /// A built distribution (wheel) that exists in the local cache. #[derive(Debug, Clone, Hash, PartialEq, Eq)] +#[allow(clippy::large_enum_variant)] pub enum CachedDist { /// The distribution exists in a registry, like `PyPI`. Registry(CachedRegistryDist), diff --git a/crates/uv-distribution-types/src/dist_error.rs b/crates/uv-distribution-types/src/dist_error.rs index d5d5ab781..a452ce663 100644 --- a/crates/uv-distribution-types/src/dist_error.rs +++ b/crates/uv-distribution-types/src/dist_error.rs @@ -1,8 +1,8 @@ use std::collections::VecDeque; use std::fmt::{Debug, Display, Formatter}; -use petgraph::prelude::EdgeRef; use petgraph::Direction; +use petgraph::prelude::EdgeRef; use rustc_hash::FxHashSet; use version_ranges::Ranges; diff --git a/crates/uv-distribution-types/src/index_url.rs b/crates/uv-distribution-types/src/index_url.rs index 4dc7d1b6e..f67063a41 100644 --- a/crates/uv-distribution-types/src/index_url.rs +++ b/crates/uv-distribution-types/src/index_url.rs @@ -10,7 +10,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use thiserror::Error; use url::{ParseError, Url}; -use uv_pep508::{split_scheme, Scheme, VerbatimUrl, VerbatimUrlError}; +use uv_pep508::{Scheme, VerbatimUrl, VerbatimUrlError, split_scheme}; use crate::{Index, IndexStatusCodeStrategy, Verbatim}; diff --git a/crates/uv-distribution-types/src/requirement.rs b/crates/uv-distribution-types/src/requirement.rs index 991eac1ea..9a2686273 100644 --- a/crates/uv-distribution-types/src/requirement.rs +++ b/crates/uv-distribution-types/src/requirement.rs @@ -7,12 +7,12 @@ use thiserror::Error; use url::Url; use uv_distribution_filename::DistExtension; -use uv_fs::{relative_to, PortablePath, PortablePathBuf, CWD}; +use uv_fs::{CWD, PortablePath, PortablePathBuf, relative_to}; use uv_git_types::{GitOid, GitReference, GitUrl, GitUrlParseError, OidParseError}; use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_pep440::VersionSpecifiers; use uv_pep508::{ - marker, MarkerEnvironment, MarkerTree, RequirementOrigin, VerbatimUrl, VersionOrUrl, + MarkerEnvironment, MarkerTree, RequirementOrigin, VerbatimUrl, VersionOrUrl, marker, }; use crate::{IndexMetadata, IndexUrl}; diff --git a/crates/uv-distribution/src/archive.rs b/crates/uv-distribution/src/archive.rs index d5668249d..5e2034087 100644 --- a/crates/uv-distribution/src/archive.rs +++ b/crates/uv-distribution/src/archive.rs @@ -1,4 +1,4 @@ -use uv_cache::{ArchiveId, Cache, ARCHIVE_VERSION}; +use uv_cache::{ARCHIVE_VERSION, ArchiveId, Cache}; use uv_distribution_filename::WheelFilename; use uv_distribution_types::Hashed; use uv_pypi_types::{HashDigest, HashDigests}; diff --git a/crates/uv-distribution/src/distribution_database.rs b/crates/uv-distribution/src/distribution_database.rs index 70c02accd..1e3d8d9ba 100644 --- a/crates/uv-distribution/src/distribution_database.rs +++ b/crates/uv-distribution/src/distribution_database.rs @@ -10,7 +10,7 @@ use tempfile::TempDir; use tokio::io::{AsyncRead, AsyncSeekExt, ReadBuf}; use tokio::sync::Semaphore; use tokio_util::compat::FuturesAsyncReadCompatExt; -use tracing::{info_span, instrument, warn, Instrument}; +use tracing::{Instrument, info_span, instrument, warn}; use url::Url; use uv_cache::{ArchiveId, CacheBucket, CacheEntry, WheelCache}; @@ -97,7 +97,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { ), ) } else { - io::Error::new(io::ErrorKind::Other, err) + io::Error::other(err) } } @@ -647,7 +647,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { archive } else { self.client - .managed(|client| async { + .managed(async |client| { client .cached_client() .skip_cache_with_retry(self.request(url)?, &http_entry, download) @@ -814,7 +814,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { archive } else { self.client - .managed(|client| async { + .managed(async |client| { client .cached_client() .skip_cache_with_retry(self.request(url)?, &http_entry, download) diff --git a/crates/uv-distribution/src/index/built_wheel_index.rs b/crates/uv-distribution/src/index/built_wheel_index.rs index 06a347e8b..fb376d1b4 100644 --- a/crates/uv-distribution/src/index/built_wheel_index.rs +++ b/crates/uv-distribution/src/index/built_wheel_index.rs @@ -8,9 +8,9 @@ use uv_distribution_types::{ use uv_platform_tags::Tags; use uv_types::HashStrategy; -use crate::index::cached_wheel::CachedWheel; -use crate::source::{HttpRevisionPointer, LocalRevisionPointer, HTTP_REVISION, LOCAL_REVISION}; use crate::Error; +use crate::index::cached_wheel::CachedWheel; +use crate::source::{HTTP_REVISION, HttpRevisionPointer, LOCAL_REVISION, LocalRevisionPointer}; /// A local index of built distributions for a specific source distribution. #[derive(Debug)] diff --git a/crates/uv-distribution/src/index/registry_wheel_index.rs b/crates/uv-distribution/src/index/registry_wheel_index.rs index 256b44d19..09f1bd5c7 100644 --- a/crates/uv-distribution/src/index/registry_wheel_index.rs +++ b/crates/uv-distribution/src/index/registry_wheel_index.rs @@ -12,7 +12,7 @@ use uv_platform_tags::Tags; use uv_types::HashStrategy; use crate::index::cached_wheel::CachedWheel; -use crate::source::{HttpRevisionPointer, LocalRevisionPointer, HTTP_REVISION, LOCAL_REVISION}; +use crate::source::{HTTP_REVISION, HttpRevisionPointer, LOCAL_REVISION, LocalRevisionPointer}; /// An entry in the [`RegistryWheelIndex`]. #[derive(Debug, Clone, Hash, PartialEq, Eq)] @@ -64,7 +64,7 @@ impl<'a> RegistryWheelIndex<'a> { /// Get an entry in the index. fn get_impl(&mut self, name: &'a PackageName) -> &[IndexEntry] { - let versions = match self.index.entry(name) { + (match self.index.entry(name) { Entry::Occupied(entry) => entry.into_mut(), Entry::Vacant(entry) => entry.insert(Self::index( name, @@ -74,8 +74,7 @@ impl<'a> RegistryWheelIndex<'a> { self.hasher, self.build_configuration, )), - }; - versions + }) as _ } /// Add a package to the index by reading from the cache. diff --git a/crates/uv-distribution/src/metadata/lowering.rs b/crates/uv-distribution/src/metadata/lowering.rs index c3dbfb894..197b9de06 100644 --- a/crates/uv-distribution/src/metadata/lowering.rs +++ b/crates/uv-distribution/src/metadata/lowering.rs @@ -13,10 +13,10 @@ use uv_distribution_types::{ use uv_git_types::{GitReference, GitUrl, GitUrlParseError}; use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_pep440::VersionSpecifiers; -use uv_pep508::{looks_like_git_repository, MarkerTree, VerbatimUrl, VersionOrUrl}; +use uv_pep508::{MarkerTree, VerbatimUrl, VersionOrUrl, looks_like_git_repository}; use uv_pypi_types::{ConflictItem, ParsedUrlError, VerbatimParsedUrl}; -use uv_workspace::pyproject::{PyProjectToml, Source, Sources}; use uv_workspace::Workspace; +use uv_workspace::pyproject::{PyProjectToml, Source, Sources}; use crate::metadata::GitWorkspaceMember; @@ -285,8 +285,7 @@ impl LoweredRequirement { // relative to main workspace: `../current_workspace/packages/current_project` let url = VerbatimUrl::from_absolute_path(member.root())?; let install_path = url.to_file_path().map_err(|()| { - LoweringError::RelativeTo(io::Error::new( - io::ErrorKind::Other, + LoweringError::RelativeTo(io::Error::other( "Invalid path in file URL", )) })?; @@ -689,12 +688,9 @@ fn path_source( RequirementOrigin::Workspace => workspace_root, }; let url = VerbatimUrl::from_path(path, base)?.with_given(path.to_string_lossy()); - let install_path = url.to_file_path().map_err(|()| { - LoweringError::RelativeTo(io::Error::new( - io::ErrorKind::Other, - "Invalid path in file URL", - )) - })?; + let install_path = url + .to_file_path() + .map_err(|()| LoweringError::RelativeTo(io::Error::other("Invalid path in file URL")))?; let is_dir = if let Ok(metadata) = install_path.metadata() { metadata.is_dir() diff --git a/crates/uv-distribution/src/metadata/requires_dist.rs b/crates/uv-distribution/src/metadata/requires_dist.rs index 393f67f4f..d728ed58b 100644 --- a/crates/uv-distribution/src/metadata/requires_dist.rs +++ b/crates/uv-distribution/src/metadata/requires_dist.rs @@ -6,14 +6,14 @@ use rustc_hash::FxHashSet; use uv_configuration::SourceStrategy; use uv_distribution_types::{IndexLocations, Requirement}; -use uv_normalize::{ExtraName, GroupName, PackageName, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, ExtraName, GroupName, PackageName}; use uv_pep508::MarkerTree; use uv_workspace::dependency_groups::FlatDependencyGroups; use uv_workspace::pyproject::{Sources, ToolUvSources}; use uv_workspace::{DiscoveryOptions, MemberDiscovery, ProjectWorkspace, WorkspaceCache}; -use crate::metadata::{GitWorkspaceMember, LoweredRequirement, MetadataError}; use crate::Metadata; +use crate::metadata::{GitWorkspaceMember, LoweredRequirement, MetadataError}; #[derive(Debug, Clone)] pub struct RequiresDist { @@ -466,8 +466,8 @@ mod test { use uv_workspace::pyproject::PyProjectToml; use uv_workspace::{DiscoveryOptions, ProjectWorkspace, WorkspaceCache}; - use crate::metadata::requires_dist::FlatRequiresDist; use crate::RequiresDist; + use crate::metadata::requires_dist::FlatRequiresDist; async fn requires_dist_from_pyproject_toml(contents: &str) -> anyhow::Result { let pyproject_toml = PyProjectToml::from_string(contents.to_string())?; diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index 717e2c769..9173106dc 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -18,7 +18,7 @@ use fs_err::tokio as fs; use futures::{FutureExt, TryStreamExt}; use reqwest::{Response, StatusCode}; use tokio_util::compat::FuturesAsyncReadCompatExt; -use tracing::{debug, info_span, instrument, warn, Instrument}; +use tracing::{Instrument, debug, info_span, instrument, warn}; use url::Url; use zip::ZipArchive; @@ -39,7 +39,7 @@ use uv_fs::{rename_with_retry, write_atomic}; use uv_git_types::{GitHubRepository, GitOid}; use uv_metadata::read_archive_metadata; use uv_normalize::PackageName; -use uv_pep440::{release_specifiers_to_ranges, Version}; +use uv_pep440::{Version, release_specifiers_to_ranges}; use uv_platform_tags::Tags; use uv_pypi_types::{HashAlgorithm, HashDigest, HashDigests, PyProjectToml, ResolutionMetadata}; use uv_types::{BuildContext, BuildStack, SourceBuildTrait}; @@ -736,7 +736,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { Ok(revision) } else { client - .managed(|client| async move { + .managed(async |client| { client .cached_client() .skip_cache_with_retry( @@ -1925,7 +1925,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { debug!("Attempting to fetch `pyproject.toml` from: {url}"); let content = client - .managed(|client| async { + .managed(async |client| { let response = client .uncached_client(git.repository()) .get(&url) @@ -2073,7 +2073,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { .instrument(info_span!("download", source_dist = %source)) }; client - .managed(|client| async move { + .managed(async |client| { client .cached_client() .skip_cache_with_retry( @@ -2107,7 +2107,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { .map_err(Error::CacheWrite)?; let reader = response .bytes_stream() - .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err)) + .map_err(std::io::Error::other) .into_async_read(); // Create a hasher for each hash algorithm. diff --git a/crates/uv-extract/src/sync.rs b/crates/uv-extract/src/sync.rs index af510f39b..b32add257 100644 --- a/crates/uv-extract/src/sync.rs +++ b/crates/uv-extract/src/sync.rs @@ -1,8 +1,8 @@ use std::path::{Path, PathBuf}; use std::sync::{LazyLock, Mutex}; -use crate::vendor::{CloneableSeekableReader, HasLength}; use crate::Error; +use crate::vendor::{CloneableSeekableReader, HasLength}; use rayon::prelude::*; use rustc_hash::FxHashSet; use tracing::warn; diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index 90838aceb..0b5055b40 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -255,7 +255,7 @@ pub async fn rename_with_retry( let from = from.as_ref(); let to = to.as_ref(); - let rename = || async { fs_err::rename(from, to) }; + let rename = async || fs_err::rename(from, to); rename .retry(backoff_file_move()) @@ -312,16 +312,13 @@ pub fn with_retry_sync( }) .call() .map_err(|err| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Failed {} {} to {}: {}", - operation_name, - from.display(), - to.display(), - err - ), - ) + std::io::Error::other(format!( + "Failed {} {} to {}: {}", + operation_name, + from.display(), + to.display(), + err + )) }) } #[cfg(not(windows))] @@ -417,21 +414,15 @@ pub async fn persist_with_retry( match persisted { Ok(_) => Ok(()), - Err(PersistRetryError::Persist(error_message)) => Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Failed to persist temporary file to {}: {}", - to.display(), - error_message, - ), - )), - Err(PersistRetryError::LostState) => Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Failed to retrieve temporary file while trying to persist to {}", - to.display() - ), - )), + Err(PersistRetryError::Persist(error_message)) => Err(std::io::Error::other(format!( + "Failed to persist temporary file to {}: {}", + to.display(), + error_message, + ))), + Err(PersistRetryError::LostState) => Err(std::io::Error::other(format!( + "Failed to retrieve temporary file while trying to persist to {}", + to.display() + ))), } } #[cfg(not(windows))] @@ -491,21 +482,15 @@ pub fn persist_with_retry_sync( match persisted { Ok(_) => Ok(()), - Err(PersistRetryError::Persist(error_message)) => Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Failed to persist temporary file to {}: {}", - to.display(), - error_message, - ), - )), - Err(PersistRetryError::LostState) => Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Failed to retrieve temporary file while trying to persist to {}", - to.display() - ), - )), + Err(PersistRetryError::Persist(error_message)) => Err(std::io::Error::other(format!( + "Failed to persist temporary file to {}: {}", + to.display(), + error_message, + ))), + Err(PersistRetryError::LostState) => Err(std::io::Error::other(format!( + "Failed to retrieve temporary file while trying to persist to {}", + to.display() + ))), } } #[cfg(not(windows))] @@ -617,14 +602,11 @@ impl LockedFile { ); file.file().lock_exclusive().map_err(|err| { // Not an fs_err method, we need to build our own path context - std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Could not acquire lock for `{resource}` at `{}`: {}", - file.path().user_display(), - err - ), - ) + std::io::Error::other(format!( + "Could not acquire lock for `{resource}` at `{}`: {}", + file.path().user_display(), + err + )) })?; debug!("Acquired lock for `{resource}`"); diff --git a/crates/uv-fs/src/path.rs b/crates/uv-fs/src/path.rs index 5bfa7a72d..7a75c76c3 100644 --- a/crates/uv-fs/src/path.rs +++ b/crates/uv-fs/src/path.rs @@ -319,14 +319,11 @@ pub fn relative_to( .map(|stripped| (stripped, ancestor)) }) .ok_or_else(|| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Trivial strip failed: {} vs. {}", - path.simplified_display(), - base.simplified_display() - ), - ) + std::io::Error::other(format!( + "Trivial strip failed: {} vs. {}", + path.simplified_display(), + base.simplified_display() + )) })?; // go as many levels up as required diff --git a/crates/uv-git/src/git.rs b/crates/uv-git/src/git.rs index af82c56fa..d31444081 100644 --- a/crates/uv-git/src/git.rs +++ b/crates/uv-git/src/git.rs @@ -8,7 +8,7 @@ use std::str::{self}; use std::sync::LazyLock; use anyhow::{Context, Result}; -use cargo_util::{paths, ProcessBuilder}; +use cargo_util::{ProcessBuilder, paths}; use reqwest::StatusCode; use reqwest_middleware::ClientWithMiddleware; use tracing::{debug, warn}; diff --git a/crates/uv-git/src/lib.rs b/crates/uv-git/src/lib.rs index 89a9d1558..ef23e58c2 100644 --- a/crates/uv-git/src/lib.rs +++ b/crates/uv-git/src/lib.rs @@ -1,4 +1,4 @@ -pub use crate::credentials::{store_credentials_from_url, GIT_STORE}; +pub use crate::credentials::{GIT_STORE, store_credentials_from_url}; pub use crate::git::GIT; pub use crate::resolver::{ GitResolver, GitResolverError, RepositoryReference, ResolvedRepositoryReference, diff --git a/crates/uv-git/src/resolver.rs b/crates/uv-git/src/resolver.rs index 9d9b216b7..9335aed4d 100644 --- a/crates/uv-git/src/resolver.rs +++ b/crates/uv-git/src/resolver.rs @@ -3,13 +3,13 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -use dashmap::mapref::one::Ref; use dashmap::DashMap; +use dashmap::mapref::one::Ref; use fs_err::tokio as fs; use reqwest_middleware::ClientWithMiddleware; use tracing::debug; -use uv_cache_key::{cache_digest, RepositoryUrl}; +use uv_cache_key::{RepositoryUrl, cache_digest}; use uv_fs::LockedFile; use uv_git_types::{GitHubRepository, GitOid, GitReference, GitUrl}; use uv_version::version; diff --git a/crates/uv-git/src/source.rs b/crates/uv-git/src/source.rs index f9acb2848..6c6b38072 100644 --- a/crates/uv-git/src/source.rs +++ b/crates/uv-git/src/source.rs @@ -11,12 +11,12 @@ use reqwest_middleware::ClientWithMiddleware; use tracing::{debug, instrument}; use url::Url; -use uv_cache_key::{cache_digest, RepositoryUrl}; +use uv_cache_key::{RepositoryUrl, cache_digest}; use uv_git_types::GitUrl; use uv_redacted::redacted_url; -use crate::git::GitRemote; use crate::GIT_STORE; +use crate::git::GitRemote; /// A remote Git source that can be checked out locally. pub struct GitSource { diff --git a/crates/uv-globfilter/src/glob_dir_filter.rs b/crates/uv-globfilter/src/glob_dir_filter.rs index fd14bffff..eaca7ee0e 100644 --- a/crates/uv-globfilter/src/glob_dir_filter.rs +++ b/crates/uv-globfilter/src/glob_dir_filter.rs @@ -1,7 +1,7 @@ use globset::{Glob, GlobSet, GlobSetBuilder}; use regex_automata::dfa; use regex_automata::dfa::Automaton; -use std::path::{Path, MAIN_SEPARATOR, MAIN_SEPARATOR_STR}; +use std::path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR, Path}; use tracing::warn; /// Chosen at a whim -Konsti @@ -32,14 +32,13 @@ impl GlobDirFilter { .iter() .map(|glob| { let main_separator = regex::escape(MAIN_SEPARATOR_STR); - let regex = glob - .regex() + + glob.regex() // We are using a custom DFA builder .strip_prefix("(?-u)") .expect("a glob is a non-unicode byte regex") // Match windows paths if applicable - .replace('/', &main_separator); - regex + .replace('/', &main_separator) }) .collect(); @@ -123,9 +122,9 @@ impl GlobDirFilter { #[cfg(test)] mod tests { - use crate::glob_dir_filter::GlobDirFilter; use crate::PortableGlobParser; - use std::path::{Path, MAIN_SEPARATOR}; + use crate::glob_dir_filter::GlobDirFilter; + use std::path::{MAIN_SEPARATOR, Path}; use tempfile::tempdir; use walkdir::WalkDir; diff --git a/crates/uv-install-wheel/src/install.rs b/crates/uv-install-wheel/src/install.rs index 9d1bb8ea1..9235a3509 100644 --- a/crates/uv-install-wheel/src/install.rs +++ b/crates/uv-install-wheel/src/install.rs @@ -15,8 +15,8 @@ use uv_pypi_types::{DirectUrl, Metadata10}; use crate::linker::{LinkMode, Locks}; use crate::wheel::{ - dist_info_metadata, find_dist_info, install_data, parse_scripts, parse_wheel_file, - read_record_file, write_installer_metadata, write_script_entrypoints, LibKind, + LibKind, dist_info_metadata, find_dist_info, install_data, parse_scripts, parse_wheel_file, + read_record_file, write_installer_metadata, write_script_entrypoints, }; use crate::{Error, Layout}; diff --git a/crates/uv-install-wheel/src/lib.rs b/crates/uv-install-wheel/src/lib.rs index 153398042..f36a699f1 100644 --- a/crates/uv-install-wheel/src/lib.rs +++ b/crates/uv-install-wheel/src/lib.rs @@ -12,8 +12,8 @@ use uv_pypi_types::Scheme; pub use install::install_wheel; pub use linker::{LinkMode, Locks}; -pub use uninstall::{uninstall_egg, uninstall_legacy_editable, uninstall_wheel, Uninstall}; -pub use wheel::{parse_wheel_file, read_record_file, LibKind}; +pub use uninstall::{Uninstall, uninstall_egg, uninstall_legacy_editable, uninstall_wheel}; +pub use wheel::{LibKind, parse_wheel_file, read_record_file}; mod install; mod linker; diff --git a/crates/uv-install-wheel/src/script.rs b/crates/uv-install-wheel/src/script.rs index cc4dbc26f..eff090571 100644 --- a/crates/uv-install-wheel/src/script.rs +++ b/crates/uv-install-wheel/src/script.rs @@ -4,7 +4,7 @@ use rustc_hash::FxHashSet; use serde::Serialize; use std::sync::LazyLock; -use crate::{wheel, Error}; +use crate::{Error, wheel}; /// A script defining the name of the runnable entrypoint and the module and function that should be /// run. @@ -109,7 +109,7 @@ pub(crate) fn scripts_from_ini( #[cfg(test)] mod test { - use crate::script::{scripts_from_ini, Script}; + use crate::script::{Script, scripts_from_ini}; #[test] fn test_valid_script_names() { diff --git a/crates/uv-install-wheel/src/uninstall.rs b/crates/uv-install-wheel/src/uninstall.rs index b824bceb9..e9bd2d72a 100644 --- a/crates/uv-install-wheel/src/uninstall.rs +++ b/crates/uv-install-wheel/src/uninstall.rs @@ -6,8 +6,8 @@ use std::sync::{LazyLock, Mutex}; use tracing::trace; use uv_fs::write_atomic_sync; -use crate::wheel::read_record_file; use crate::Error; +use crate::wheel::read_record_file; /// Uninstall the wheel represented by the given `.dist-info` directory. pub fn uninstall_wheel(dist_info: &Path) -> Result { @@ -261,11 +261,7 @@ pub fn uninstall_legacy_editable(egg_link: &Path) -> Result { .lines() .find_map(|line| { let line = line.trim(); - if line.is_empty() { - None - } else { - Some(line) - } + if line.is_empty() { None } else { Some(line) } }) .ok_or_else(|| Error::InvalidEggLink(egg_link.to_path_buf()))?; diff --git a/crates/uv-install-wheel/src/wheel.rs b/crates/uv-install-wheel/src/wheel.rs index fdde62526..0661aa6b2 100644 --- a/crates/uv-install-wheel/src/wheel.rs +++ b/crates/uv-install-wheel/src/wheel.rs @@ -13,7 +13,7 @@ use tracing::{debug, instrument, trace, warn}; use walkdir::WalkDir; use uv_cache_info::CacheInfo; -use uv_fs::{persist_with_retry_sync, relative_to, Simplified}; +use uv_fs::{Simplified, persist_with_retry_sync, relative_to}; use uv_normalize::PackageName; use uv_pypi_types::DirectUrl; use uv_shell::escape_posix_for_single_quotes; @@ -21,7 +21,7 @@ use uv_trampoline_builder::windows_script_launcher; use uv_warnings::warn_user_once; use crate::record::RecordEntry; -use crate::script::{scripts_from_ini, Script}; +use crate::script::{Script, scripts_from_ini}; use crate::{Error, Layout}; /// Wrapper script template function @@ -210,13 +210,10 @@ pub(crate) fn write_script_entrypoints( let entrypoint_relative = pathdiff::diff_paths(&entrypoint_absolute, site_packages) .ok_or_else(|| { - Error::Io(io::Error::new( - io::ErrorKind::Other, - format!( - "Could not find relative path for: {}", - entrypoint_absolute.simplified_display() - ), - )) + Error::Io(io::Error::other(format!( + "Could not find relative path for: {}", + entrypoint_absolute.simplified_display() + ))) })?; // Generate the launcher script. @@ -407,13 +404,10 @@ fn install_script( let script_absolute = layout.scheme.scripts.join(file.file_name()); let script_relative = pathdiff::diff_paths(&script_absolute, site_packages).ok_or_else(|| { - Error::Io(io::Error::new( - io::ErrorKind::Other, - format!( - "Could not find relative path for: {}", - script_absolute.simplified_display() - ), - )) + Error::Io(io::Error::other(format!( + "Could not find relative path for: {}", + script_absolute.simplified_display() + ))) })?; let path = file.path(); @@ -723,13 +717,10 @@ pub(crate) fn get_relocatable_executable( ) -> Result { Ok(if relocatable { pathdiff::diff_paths(&executable, &layout.scheme.scripts).ok_or_else(|| { - Error::Io(io::Error::new( - io::ErrorKind::Other, - format!( - "Could not find relative path for: {}", - executable.simplified_display() - ), - )) + Error::Io(io::Error::other(format!( + "Could not find relative path for: {}", + executable.simplified_display() + ))) })? } else { executable @@ -896,12 +887,12 @@ mod test { use assert_fs::prelude::*; use indoc::{formatdoc, indoc}; - use crate::wheel::format_shebang; use crate::Error; + use crate::wheel::format_shebang; use super::{ - get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, - write_installer_metadata, RecordEntry, Script, + RecordEntry, Script, get_script_executable, parse_email_message_file, parse_wheel_file, + read_record_file, write_installer_metadata, }; #[test] diff --git a/crates/uv-installer/src/installer.rs b/crates/uv-installer/src/installer.rs index cd4ec9f7e..d81b8fa98 100644 --- a/crates/uv-installer/src/installer.rs +++ b/crates/uv-installer/src/installer.rs @@ -17,8 +17,10 @@ pub struct Installer<'a> { link_mode: LinkMode, cache: Option<&'a Cache>, reporter: Option>, - installer_name: Option, - installer_metadata: bool, + /// The name of the [`Installer`]. + name: Option, + /// The metadata associated with the [`Installer`]. + metadata: bool, } impl<'a> Installer<'a> { @@ -29,8 +31,8 @@ impl<'a> Installer<'a> { link_mode: LinkMode::default(), cache: None, reporter: None, - installer_name: Some("uv".to_string()), - installer_metadata: true, + name: Some("uv".to_string()), + metadata: true, } } @@ -62,7 +64,7 @@ impl<'a> Installer<'a> { #[must_use] pub fn with_installer_name(self, installer_name: Option) -> Self { Self { - installer_name, + name: installer_name, ..self } } @@ -71,7 +73,7 @@ impl<'a> Installer<'a> { #[must_use] pub fn with_installer_metadata(self, installer_metadata: bool) -> Self { Self { - installer_metadata, + metadata: installer_metadata, ..self } } @@ -84,8 +86,8 @@ impl<'a> Installer<'a> { cache, link_mode, reporter, - installer_name, - installer_metadata, + name: installer_name, + metadata: installer_metadata, } = self; if cache.is_some_and(Cache::is_temporary) { @@ -136,11 +138,11 @@ impl<'a> Installer<'a> { install( wheels, self.venv.interpreter().layout(), - self.installer_name, + self.name, self.link_mode, self.reporter, self.venv.relocatable(), - self.installer_metadata, + self.metadata, ) } } diff --git a/crates/uv-installer/src/lib.rs b/crates/uv-installer/src/lib.rs index 1f5b333bd..414f8f245 100644 --- a/crates/uv-installer/src/lib.rs +++ b/crates/uv-installer/src/lib.rs @@ -1,9 +1,9 @@ -pub use compile::{compile_tree, CompileError}; +pub use compile::{CompileError, compile_tree}; pub use installer::{Installer, Reporter as InstallReporter}; pub use plan::{Plan, Planner}; pub use preparer::{Error as PrepareError, Preparer, Reporter as PrepareReporter}; pub use site_packages::{SatisfiesResult, SitePackages, SitePackagesDiagnostic}; -pub use uninstall::{uninstall, UninstallError}; +pub use uninstall::{UninstallError, uninstall}; mod compile; mod preparer; diff --git a/crates/uv-installer/src/plan.rs b/crates/uv-installer/src/plan.rs index dd2bbcc79..e030e9b4d 100644 --- a/crates/uv-installer/src/plan.rs +++ b/crates/uv-installer/src/plan.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use std::sync::Arc; use tracing::{debug, warn}; @@ -18,8 +18,8 @@ use uv_pypi_types::VerbatimParsedUrl; use uv_python::PythonEnvironment; use uv_types::HashStrategy; -use crate::satisfies::RequirementSatisfaction; use crate::SitePackages; +use crate::satisfies::RequirementSatisfaction; /// A planner to generate an [`Plan`] based on a set of requirements. #[derive(Debug)] diff --git a/crates/uv-installer/src/preparer.rs b/crates/uv-installer/src/preparer.rs index b4ba673d1..eaf3b5b6d 100644 --- a/crates/uv-installer/src/preparer.rs +++ b/crates/uv-installer/src/preparer.rs @@ -1,7 +1,7 @@ use std::cmp::Reverse; use std::sync::Arc; -use futures::{stream::FuturesUnordered, FutureExt, Stream, TryFutureExt, TryStreamExt}; +use futures::{FutureExt, Stream, TryFutureExt, TryStreamExt, stream::FuturesUnordered}; use tracing::{debug, instrument}; use url::Url; @@ -70,7 +70,7 @@ impl<'a, Context: BuildContext> Preparer<'a, Context> { ) -> impl Stream> + 'stream { distributions .into_iter() - .map(|dist| async move { + .map(async |dist| { let wheel = self .get_wheel((*dist).clone(), in_flight, resolution) .boxed_local() diff --git a/crates/uv-installer/src/satisfies.rs b/crates/uv-installer/src/satisfies.rs index 5ff2d2d95..a91676595 100644 --- a/crates/uv-installer/src/satisfies.rs +++ b/crates/uv-installer/src/satisfies.rs @@ -25,8 +25,7 @@ impl RequirementSatisfaction { pub(crate) fn check(distribution: &InstalledDist, source: &RequirementSource) -> Self { trace!( "Comparing installed with source: {:?} {:?}", - distribution, - source + distribution, source ); // Filter out already-installed packages. match source { @@ -194,8 +193,7 @@ impl RequirementSatisfaction { { trace!( "Path mismatch: {:?} vs. {:?}", - requested_path, - installed_path, + requested_path, installed_path, ); return Self::Mismatch; } @@ -264,8 +262,7 @@ impl RequirementSatisfaction { { trace!( "Path mismatch: {:?} vs. {:?}", - requested_path, - installed_path, + requested_path, installed_path, ); return Self::Mismatch; } diff --git a/crates/uv-macros/Cargo.toml b/crates/uv-macros/Cargo.toml index 38e4be48c..f4e1fed0b 100644 --- a/crates/uv-macros/Cargo.toml +++ b/crates/uv-macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-macros" version = "0.0.1" -edition = "2021" +edition = { workspace = true } [lib] proc-macro = true diff --git a/crates/uv-macros/src/lib.rs b/crates/uv-macros/src/lib.rs index c2fadad2c..8c29fbaf2 100644 --- a/crates/uv-macros/src/lib.rs +++ b/crates/uv-macros/src/lib.rs @@ -2,7 +2,7 @@ mod options_metadata; use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, Attribute, DeriveInput, ImplItem, ItemImpl, LitStr}; +use syn::{Attribute, DeriveInput, ImplItem, ItemImpl, LitStr, parse_macro_input}; #[proc_macro_derive(OptionsMetadata, attributes(option, doc, option_group))] pub fn derive_options_metadata(input: TokenStream) -> TokenStream { @@ -38,7 +38,7 @@ fn impl_combine(ast: &DeriveInput) -> TokenStream { } }); - let gen = quote! { + let stream = quote! { impl crate::Combine for #name { fn combine(self, other: #name) -> #name { #name { @@ -47,7 +47,7 @@ fn impl_combine(ast: &DeriveInput) -> TokenStream { } } }; - gen.into() + stream.into() } fn get_doc_comment(attrs: &[Attribute]) -> String { diff --git a/crates/uv-macros/src/options_metadata.rs b/crates/uv-macros/src/options_metadata.rs index afb15f161..127ccae14 100644 --- a/crates/uv-macros/src/options_metadata.rs +++ b/crates/uv-macros/src/options_metadata.rs @@ -301,15 +301,24 @@ fn parse_field_attributes(attribute: &Attribute) -> syn::Result })?; let Some(default) = default else { - return Err(syn::Error::new(attribute.span(), "Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default=\"..\")]`.")); + return Err(syn::Error::new( + attribute.span(), + "Mandatory `default` field is missing in `#[option]` attribute. Specify the default using `#[option(default=\"..\")]`.", + )); }; let Some(value_type) = value_type else { - return Err(syn::Error::new(attribute.span(), "Mandatory `value_type` field is missing in `#[option]` attribute. Specify the value type using `#[option(value_type=\"..\")]`.")); + return Err(syn::Error::new( + attribute.span(), + "Mandatory `value_type` field is missing in `#[option]` attribute. Specify the value type using `#[option(value_type=\"..\")]`.", + )); }; let Some(example) = example else { - return Err(syn::Error::new(attribute.span(), "Mandatory `example` field is missing in `#[option]` attribute. Add an example using `#[option(example=\"..\")]`.")); + return Err(syn::Error::new( + attribute.span(), + "Mandatory `example` field is missing in `#[option]` attribute. Add an example using `#[option(example=\"..\")]`.", + )); }; Ok(FieldAttributes { diff --git a/crates/uv-normalize/Cargo.toml b/crates/uv-normalize/Cargo.toml index d40faf3d7..e22fe87c7 100644 --- a/crates/uv-normalize/Cargo.toml +++ b/crates/uv-normalize/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-normalize" version = "0.0.1" -edition = "2021" +edition = { workspace = true } description = "Normalization for distribution, package and extra names." [lib] diff --git a/crates/uv-normalize/src/extra_name.rs b/crates/uv-normalize/src/extra_name.rs index fc4ae7e7f..00aa0f090 100644 --- a/crates/uv-normalize/src/extra_name.rs +++ b/crates/uv-normalize/src/extra_name.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use uv_small_str::SmallString; -use crate::{validate_and_normalize_ref, InvalidNameError}; +use crate::{InvalidNameError, validate_and_normalize_ref}; /// Either the literal "all" or a list of extras #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/crates/uv-normalize/src/group_name.rs b/crates/uv-normalize/src/group_name.rs index 7fc4f0e3b..6b9ab14bd 100644 --- a/crates/uv-normalize/src/group_name.rs +++ b/crates/uv-normalize/src/group_name.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use uv_small_str::SmallString; use crate::{ - validate_and_normalize_ref, InvalidNameError, InvalidPipGroupError, InvalidPipGroupPathError, + InvalidNameError, InvalidPipGroupError, InvalidPipGroupPathError, validate_and_normalize_ref, }; /// The normalized name of a dependency group. diff --git a/crates/uv-normalize/src/lib.rs b/crates/uv-normalize/src/lib.rs index c1f5906ec..cdc2d76df 100644 --- a/crates/uv-normalize/src/lib.rs +++ b/crates/uv-normalize/src/lib.rs @@ -3,7 +3,7 @@ use std::fmt::{Display, Formatter}; pub use dist_info_name::DistInfoName; pub use extra_name::{DefaultExtras, ExtraName}; -pub use group_name::{DefaultGroups, GroupName, PipGroupName, DEV_DEPENDENCIES}; +pub use group_name::{DEV_DEPENDENCIES, DefaultGroups, GroupName, PipGroupName}; pub use package_name::PackageName; use uv_small_str::SmallString; diff --git a/crates/uv-normalize/src/package_name.rs b/crates/uv-normalize/src/package_name.rs index c4c0cc22e..4bd9fbec6 100644 --- a/crates/uv-normalize/src/package_name.rs +++ b/crates/uv-normalize/src/package_name.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use uv_small_str::SmallString; -use crate::{validate_and_normalize_ref, InvalidNameError}; +use crate::{InvalidNameError, validate_and_normalize_ref}; /// The normalized name of a package. /// @@ -51,13 +51,11 @@ impl PackageName { owned_string.push('_'); // Iterate over the rest of the string. - owned_string.extend(self.0[dash_position + 1..].chars().map(|character| { - if character == '-' { - '_' - } else { - character - } - })); + owned_string.extend( + self.0[dash_position + 1..] + .chars() + .map(|character| if character == '-' { '_' } else { character }), + ); Cow::Owned(owned_string) } else { diff --git a/crates/uv-pep440/src/lib.rs b/crates/uv-pep440/src/lib.rs index d622a659b..3d2e256ae 100644 --- a/crates/uv-pep440/src/lib.rs +++ b/crates/uv-pep440/src/lib.rs @@ -25,13 +25,13 @@ #[cfg(feature = "version-ranges")] pub use version_ranges::{ - release_specifier_to_range, release_specifiers_to_ranges, LowerBound, UpperBound, + LowerBound, UpperBound, release_specifier_to_range, release_specifiers_to_ranges, }; pub use { version::{ - LocalSegment, LocalVersion, LocalVersionSlice, Operator, OperatorParseError, Prerelease, - PrereleaseKind, Version, VersionParseError, VersionPattern, VersionPatternParseError, - MIN_VERSION, + LocalSegment, LocalVersion, LocalVersionSlice, MIN_VERSION, Operator, OperatorParseError, + Prerelease, PrereleaseKind, Version, VersionParseError, VersionPattern, + VersionPatternParseError, }, version_specifier::{ VersionSpecifier, VersionSpecifierBuildError, VersionSpecifiers, diff --git a/crates/uv-pep440/src/version.rs b/crates/uv-pep440/src/version.rs index b5a5c3e91..59f090927 100644 --- a/crates/uv-pep440/src/version.rs +++ b/crates/uv-pep440/src/version.rs @@ -1,4 +1,4 @@ -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use std::fmt::Formatter; use std::num::NonZero; use std::ops::Deref; diff --git a/crates/uv-pep440/src/version_specifier.rs b/crates/uv-pep440/src/version_specifier.rs index fff0be28f..47bde78b7 100644 --- a/crates/uv-pep440/src/version_specifier.rs +++ b/crates/uv-pep440/src/version_specifier.rs @@ -5,9 +5,9 @@ use std::ops::Bound; use std::str::FromStr; use crate::{ - version, Operator, OperatorParseError, Version, VersionPattern, VersionPatternParseError, + Operator, OperatorParseError, Version, VersionPattern, VersionPatternParseError, version, }; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; #[cfg(feature = "tracing")] use tracing::warn; @@ -828,15 +828,21 @@ mod tests { fn test_equal() { let version = Version::from_str("1.1.post1").unwrap(); - assert!(!VersionSpecifier::from_str("== 1.1") - .unwrap() - .contains(&version)); - assert!(VersionSpecifier::from_str("== 1.1.post1") - .unwrap() - .contains(&version)); - assert!(VersionSpecifier::from_str("== 1.1.*") - .unwrap() - .contains(&version)); + assert!( + !VersionSpecifier::from_str("== 1.1") + .unwrap() + .contains(&version) + ); + assert!( + VersionSpecifier::from_str("== 1.1.post1") + .unwrap() + .contains(&version) + ); + assert!( + VersionSpecifier::from_str("== 1.1.*") + .unwrap() + .contains(&version) + ); } const VERSIONS_ALL: &[&str] = &[ @@ -1087,12 +1093,16 @@ mod tests { #[test] fn test_arbitrary_equality() { - assert!(VersionSpecifier::from_str("=== 1.2a1") - .unwrap() - .contains(&Version::from_str("1.2a1").unwrap())); - assert!(!VersionSpecifier::from_str("=== 1.2a1") - .unwrap() - .contains(&Version::from_str("1.2a1+local").unwrap())); + assert!( + VersionSpecifier::from_str("=== 1.2a1") + .unwrap() + .contains(&Version::from_str("1.2a1").unwrap()) + ); + assert!( + !VersionSpecifier::from_str("=== 1.2a1") + .unwrap() + .contains(&Version::from_str("1.2a1+local").unwrap()) + ); } #[test] diff --git a/crates/uv-pep508/src/lib.rs b/crates/uv-pep508/src/lib.rs index 50440a6e2..a78678d92 100644 --- a/crates/uv-pep508/src/lib.rs +++ b/crates/uv-pep508/src/lib.rs @@ -21,7 +21,7 @@ use std::fmt::{Debug, Display, Formatter}; use std::path::Path; use std::str::FromStr; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use thiserror::Error; use url::Url; @@ -42,8 +42,8 @@ pub use uv_normalize::{ExtraName, InvalidNameError, PackageName}; pub use uv_pep440; use uv_pep440::{VersionSpecifier, VersionSpecifiers}; pub use verbatim_url::{ - expand_env_vars, looks_like_git_repository, split_scheme, strip_host, Scheme, VerbatimUrl, - VerbatimUrlError, + Scheme, VerbatimUrl, VerbatimUrlError, expand_env_vars, looks_like_git_repository, + split_scheme, strip_host, }; mod cursor; @@ -980,7 +980,7 @@ mod tests { use uv_pep440::{Operator, Version, VersionPattern, VersionSpecifier}; use crate::cursor::Cursor; - use crate::marker::{parse, MarkerExpression, MarkerTree, MarkerValueVersion}; + use crate::marker::{MarkerExpression, MarkerTree, MarkerValueVersion, parse}; use crate::{ MarkerOperator, MarkerValueString, Requirement, TracingReporter, VerbatimUrl, VersionOrUrl, }; diff --git a/crates/uv-pep508/src/marker/algebra.rs b/crates/uv-pep508/src/marker/algebra.rs index ba9778fac..f421a8fa3 100644 --- a/crates/uv-pep508/src/marker/algebra.rs +++ b/crates/uv-pep508/src/marker/algebra.rs @@ -55,12 +55,12 @@ use itertools::{Either, Itertools}; use rustc_hash::FxHashMap; use version_ranges::Ranges; -use uv_pep440::{release_specifier_to_range, Operator, Version, VersionSpecifier}; +use uv_pep440::{Operator, Version, VersionSpecifier, release_specifier_to_range}; +use crate::marker::MarkerValueExtra; use crate::marker::lowering::{ CanonicalMarkerValueExtra, CanonicalMarkerValueString, CanonicalMarkerValueVersion, }; -use crate::marker::MarkerValueExtra; use crate::{ ExtraOperator, MarkerExpression, MarkerOperator, MarkerValueString, MarkerValueVersion, }; @@ -153,11 +153,7 @@ impl InternerGuard<'_> { .entry(node.clone()) .or_insert_with(|| NodeId::new(self.shared.nodes.push(node), false)); - if flipped { - id.not() - } else { - *id - } + if flipped { id.not() } else { *id } } /// Returns a decision node for a single marker expression. @@ -1708,7 +1704,7 @@ impl fmt::Debug for NodeId { #[cfg(test)] mod tests { - use super::{NodeId, INTERNER}; + use super::{INTERNER, NodeId}; use crate::MarkerExpression; fn expr(s: &str) -> NodeId { diff --git a/crates/uv-pep508/src/marker/tree.rs b/crates/uv-pep508/src/marker/tree.rs index aec9d4734..070a24b26 100644 --- a/crates/uv-pep508/src/marker/tree.rs +++ b/crates/uv-pep508/src/marker/tree.rs @@ -6,13 +6,13 @@ use std::str::FromStr; use arcstr::ArcStr; use itertools::Itertools; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use version_ranges::Ranges; use uv_normalize::ExtraName; use uv_pep440::{Version, VersionParseError, VersionSpecifier}; -use super::algebra::{Edges, NodeId, Variable, INTERNER}; +use super::algebra::{Edges, INTERNER, NodeId, Variable}; use super::simplify; use crate::cursor::Cursor; use crate::marker::lowering::{ @@ -2967,9 +2967,11 @@ mod test { #[test] fn test_is_false() { assert!(m("python_version < '3.10' and python_version >= '3.10'").is_false()); - assert!(m("(python_version < '3.10' and python_version >= '3.10') \ + assert!( + m("(python_version < '3.10' and python_version >= '3.10') \ or (python_version < '3.9' and python_version >= '3.9')") - .is_false()); + .is_false() + ); assert!(!m("python_version < '3.10'").is_false()); assert!(!m("python_version < '0'").is_false()); @@ -3226,11 +3228,13 @@ mod test { m("os_name == 'Linux'"), ); - assert!(m(" + assert!( + m(" (os_name == 'Linux' and extra == 'foo') or (os_name != 'Linux' and extra == 'bar')") - .without_extras() - .is_true()); + .without_extras() + .is_true() + ); assert_eq!( m("os_name == 'Linux' and extra != 'foo'").without_extras(), @@ -3259,11 +3263,13 @@ mod test { m("os_name == 'Linux' and extra == 'foo'").only_extras(), m("extra == 'foo'"), ); - assert!(m(" + assert!( + m(" (os_name == 'foo' and extra == 'foo') or (os_name == 'bar' and extra != 'foo')") - .only_extras() - .is_true()); + .only_extras() + .is_true() + ); assert_eq!( m(" (os_name == 'Linux' and extra == 'foo') diff --git a/crates/uv-pep508/src/unnamed.rs b/crates/uv-pep508/src/unnamed.rs index 4259cff54..cbde5fb06 100644 --- a/crates/uv-pep508/src/unnamed.rs +++ b/crates/uv-pep508/src/unnamed.rs @@ -8,9 +8,9 @@ use uv_normalize::ExtraName; use crate::marker::parse; use crate::{ - expand_env_vars, parse_extras_cursor, split_extras, split_scheme, strip_host, Cursor, - MarkerEnvironment, MarkerTree, Pep508Error, Pep508ErrorSource, Pep508Url, Reporter, - RequirementOrigin, Scheme, TracingReporter, VerbatimUrl, VerbatimUrlError, + Cursor, MarkerEnvironment, MarkerTree, Pep508Error, Pep508ErrorSource, Pep508Url, Reporter, + RequirementOrigin, Scheme, TracingReporter, VerbatimUrl, VerbatimUrlError, expand_env_vars, + parse_extras_cursor, split_extras, split_scheme, strip_host, }; /// An extension over [`Pep508Url`] that also supports parsing unnamed requirements, namely paths. @@ -19,7 +19,7 @@ use crate::{ pub trait UnnamedRequirementUrl: Pep508Url { /// Parse a URL from a relative or absolute path. fn parse_path(path: impl AsRef, working_dir: impl AsRef) - -> Result; + -> Result; /// Parse a URL from an absolute path. fn parse_absolute_path(path: impl AsRef) -> Result; diff --git a/crates/uv-performance-memory-allocator/Cargo.toml b/crates/uv-performance-memory-allocator/Cargo.toml index 36ab5d6a1..fabba9721 100644 --- a/crates/uv-performance-memory-allocator/Cargo.toml +++ b/crates/uv-performance-memory-allocator/Cargo.toml @@ -2,7 +2,7 @@ name = "uv-performance-memory-allocator" version = "0.1.0" publish = false -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/crates/uv-platform-tags/src/language_tag.rs b/crates/uv-platform-tags/src/language_tag.rs index 8641664de..8bec60bc5 100644 --- a/crates/uv-platform-tags/src/language_tag.rs +++ b/crates/uv-platform-tags/src/language_tag.rs @@ -236,8 +236,8 @@ pub enum ParseLanguageTagError { mod tests { use std::str::FromStr; - use crate::language_tag::ParseLanguageTagError; use crate::LanguageTag; + use crate::language_tag::ParseLanguageTagError; #[test] fn none() { diff --git a/crates/uv-publish/src/lib.rs b/crates/uv-publish/src/lib.rs index 342109fad..72e4d102a 100644 --- a/crates/uv-publish/src/lib.rs +++ b/crates/uv-publish/src/lib.rs @@ -7,7 +7,7 @@ use std::{env, fmt, io}; use fs_err::tokio::File; use futures::TryStreamExt; -use glob::{glob, GlobError, PatternError}; +use glob::{GlobError, PatternError, glob}; use itertools::Itertools; use reqwest::header::AUTHORIZATION; use reqwest::multipart::Part; @@ -21,15 +21,15 @@ use thiserror::Error; use tokio::io::{AsyncReadExt, BufReader}; use tokio::sync::Semaphore; use tokio_util::io::ReaderStream; -use tracing::{debug, enabled, trace, warn, Level}; +use tracing::{Level, debug, enabled, trace, warn}; use trusted_publishing::TrustedPublishingToken; use url::Url; use uv_auth::Credentials; use uv_cache::{Cache, Refresh}; use uv_client::{ - BaseClient, MetadataFormat, OwnedArchive, RegistryClientBuilder, UvRetryableStrategy, - DEFAULT_RETRIES, + BaseClient, DEFAULT_RETRIES, MetadataFormat, OwnedArchive, RegistryClientBuilder, + UvRetryableStrategy, }; use uv_configuration::{KeyringProviderType, TrustedPublishing}; use uv_distribution_filename::{DistFilename, SourceDistExtension, SourceDistFilename}; @@ -243,6 +243,7 @@ impl PublishSendError { /// caused by /// in combination with /// +#[allow(clippy::result_large_err)] pub fn files_for_publishing( paths: Vec, ) -> Result, PublishError> { @@ -585,7 +586,7 @@ async fn source_dist_pkg_info(file: &Path) -> Result, PublishPrepareErro let mut pkg_infos: Vec<(PathBuf, Vec)> = archive .entries()? .map_err(PublishPrepareError::from) - .try_filter_map(|mut entry| async move { + .try_filter_map(async |mut entry| { let path = entry .path() .map_err(PublishPrepareError::from)? @@ -883,7 +884,7 @@ async fn handle_response(registry: &Url, response: Response) -> Result<(), Publi #[cfg(test)] mod tests { - use crate::{build_request, form_metadata, Reporter}; + use crate::{Reporter, build_request, form_metadata}; use insta::{assert_debug_snapshot, assert_snapshot}; use itertools::Itertools; use std::path::PathBuf; diff --git a/crates/uv-publish/src/trusted_publishing.rs b/crates/uv-publish/src/trusted_publishing.rs index 23d516456..bdbc8077d 100644 --- a/crates/uv-publish/src/trusted_publishing.rs +++ b/crates/uv-publish/src/trusted_publishing.rs @@ -1,8 +1,8 @@ //! Trusted publishing (via OIDC) with GitHub actions. -use base64::prelude::BASE64_URL_SAFE_NO_PAD; use base64::Engine; -use reqwest::{header, StatusCode}; +use base64::prelude::BASE64_URL_SAFE_NO_PAD; +use reqwest::{StatusCode, header}; use reqwest_middleware::ClientWithMiddleware; use serde::{Deserialize, Serialize}; use std::env; diff --git a/crates/uv-pypi-types/src/lenient_requirement.rs b/crates/uv-pypi-types/src/lenient_requirement.rs index 0537c2ca7..72ecef485 100644 --- a/crates/uv-pypi-types/src/lenient_requirement.rs +++ b/crates/uv-pypi-types/src/lenient_requirement.rs @@ -1,5 +1,5 @@ use regex::Regex; -use serde::{de, Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Deserializer, Serialize, de}; use std::borrow::Cow; use std::str::FromStr; use std::sync::LazyLock; diff --git a/crates/uv-pypi-types/src/metadata/metadata10.rs b/crates/uv-pypi-types/src/metadata/metadata10.rs index 57113f1f0..559570fbb 100644 --- a/crates/uv-pypi-types/src/metadata/metadata10.rs +++ b/crates/uv-pypi-types/src/metadata/metadata10.rs @@ -2,8 +2,8 @@ use serde::Deserialize; use uv_normalize::PackageName; -use crate::metadata::Headers; use crate::MetadataError; +use crate::metadata::Headers; /// A subset of the full core metadata specification, including only the /// fields that have been consistent across all versions of the specification. diff --git a/crates/uv-pypi-types/src/metadata/metadata23.rs b/crates/uv-pypi-types/src/metadata/metadata23.rs index cd934a25d..b0c1235be 100644 --- a/crates/uv-pypi-types/src/metadata/metadata23.rs +++ b/crates/uv-pypi-types/src/metadata/metadata23.rs @@ -5,8 +5,8 @@ use std::fmt::Write; use std::str; use std::str::FromStr; -use crate::metadata::Headers; use crate::MetadataError; +use crate::metadata::Headers; /// Code Metadata 2.3 as specified in /// . diff --git a/crates/uv-pypi-types/src/metadata/metadata_resolver.rs b/crates/uv-pypi-types/src/metadata/metadata_resolver.rs index 7f310b9af..8f90b3614 100644 --- a/crates/uv-pypi-types/src/metadata/metadata_resolver.rs +++ b/crates/uv-pypi-types/src/metadata/metadata_resolver.rs @@ -11,9 +11,9 @@ use uv_pep440::{Version, VersionSpecifiers}; use uv_pep508::Requirement; use crate::lenient_requirement::LenientRequirement; -use crate::metadata::pyproject_toml::PyProjectToml; use crate::metadata::Headers; -use crate::{metadata, LenientVersionSpecifiers, MetadataError, VerbatimParsedUrl}; +use crate::metadata::pyproject_toml::PyProjectToml; +use crate::{LenientVersionSpecifiers, MetadataError, VerbatimParsedUrl, metadata}; /// A subset of the full core metadata specification, including only the /// fields that are relevant to dependency resolution. diff --git a/crates/uv-pypi-types/src/metadata/mod.rs b/crates/uv-pypi-types/src/metadata/mod.rs index d18767ac5..0ef7f2321 100644 --- a/crates/uv-pypi-types/src/metadata/mod.rs +++ b/crates/uv-pypi-types/src/metadata/mod.rs @@ -18,9 +18,9 @@ use uv_pep508::Pep508Error; use crate::VerbatimParsedUrl; pub use build_requires::BuildRequires; +pub use metadata_resolver::ResolutionMetadata; pub use metadata10::Metadata10; pub use metadata23::Metadata23; -pub use metadata_resolver::ResolutionMetadata; pub use pyproject_toml::PyProjectToml; pub use requires_dist::RequiresDist; pub use requires_txt::RequiresTxt; diff --git a/crates/uv-pypi-types/src/metadata/pyproject_toml.rs b/crates/uv-pypi-types/src/metadata/pyproject_toml.rs index e8d162f9a..113021a34 100644 --- a/crates/uv-pypi-types/src/metadata/pyproject_toml.rs +++ b/crates/uv-pypi-types/src/metadata/pyproject_toml.rs @@ -1,8 +1,8 @@ use std::str::FromStr; use indexmap::IndexMap; -use serde::de::IntoDeserializer; use serde::Deserialize; +use serde::de::IntoDeserializer; use uv_normalize::{ExtraName, PackageName}; use uv_pep440::Version; diff --git a/crates/uv-pypi-types/src/parsed_url.rs b/crates/uv-pypi-types/src/parsed_url.rs index 37fef5a7b..c918c1cf1 100644 --- a/crates/uv-pypi-types/src/parsed_url.rs +++ b/crates/uv-pypi-types/src/parsed_url.rs @@ -7,7 +7,7 @@ use url::{ParseError, Url}; use uv_distribution_filename::{DistExtension, ExtensionError}; use uv_git_types::{GitUrl, GitUrlParseError}; use uv_pep508::{ - looks_like_git_repository, Pep508Url, UnnamedRequirementUrl, VerbatimUrl, VerbatimUrlError, + Pep508Url, UnnamedRequirementUrl, VerbatimUrl, VerbatimUrlError, looks_like_git_repository, }; use crate::{ArchiveInfo, DirInfo, DirectUrl, VcsInfo, VcsKind}; diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index 9b7f6c2dd..a90b26d65 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -11,11 +11,11 @@ use tracing::{debug, instrument, trace}; use which::{which, which_all}; use uv_cache::Cache; -use uv_fs::which::is_executable; use uv_fs::Simplified; +use uv_fs::which::is_executable; use uv_pep440::{ - release_specifiers_to_ranges, LowerBound, Prerelease, UpperBound, Version, VersionSpecifier, - VersionSpecifiers, + LowerBound, Prerelease, UpperBound, Version, VersionSpecifier, VersionSpecifiers, + release_specifiers_to_ranges, }; use uv_static::EnvVars; use uv_warnings::warn_user_once; @@ -30,11 +30,11 @@ use crate::managed::ManagedPythonInstallations; use crate::microsoft_store::find_microsoft_store_pythons; use crate::virtualenv::Error as VirtualEnvError; use crate::virtualenv::{ - conda_environment_from_env, virtualenv_from_env, virtualenv_from_working_dir, - virtualenv_python_executable, CondaEnvironmentKind, + CondaEnvironmentKind, conda_environment_from_env, virtualenv_from_env, + virtualenv_from_working_dir, virtualenv_python_executable, }; #[cfg(windows)] -use crate::windows_registry::{registry_pythons, WindowsPython}; +use crate::windows_registry::{WindowsPython, registry_pythons}; use crate::{BrokenSymlink, Interpreter, PythonVersion}; /// A request to find a Python installation. @@ -251,8 +251,8 @@ pub enum Error { /// - Discovered virtual environment (e.g. `.venv` in a parent directory) /// /// Notably, "system" environments are excluded. See [`python_executables_from_installed`]. -fn python_executables_from_virtual_environments<'a>( -) -> impl Iterator> + 'a { +fn python_executables_from_virtual_environments<'a>() +-> impl Iterator> + 'a { let from_active_environment = iter::once_with(|| { virtualenv_from_env() .into_iter() @@ -1252,8 +1252,8 @@ pub(crate) fn is_windows_store_shim(path: &Path) -> bool { CreateFileW, FILE_ATTRIBUTE_REPARSE_POINT, FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, OPEN_EXISTING, }; - use windows_sys::Win32::System::Ioctl::FSCTL_GET_REPARSE_POINT; use windows_sys::Win32::System::IO::DeviceIoControl; + use windows_sys::Win32::System::Ioctl::FSCTL_GET_REPARSE_POINT; // The path must be absolute. if !path.is_absolute() { @@ -2715,7 +2715,7 @@ fn split_wheel_tag_release_version(version: Version) -> Version { mod tests { use std::{path::PathBuf, str::FromStr}; - use assert_fs::{prelude::*, TempDir}; + use assert_fs::{TempDir, prelude::*}; use target_lexicon::{Aarch64Architecture, Architecture}; use test_log::test; use uv_pep440::{Prerelease, PrereleaseKind, VersionSpecifiers}; diff --git a/crates/uv-python/src/downloads.rs b/crates/uv-python/src/downloads.rs index 8ae20f7e7..c4a342856 100644 --- a/crates/uv-python/src/downloads.rs +++ b/crates/uv-python/src/downloads.rs @@ -21,13 +21,14 @@ use tokio_util::either::Either; use tracing::{debug, instrument}; use url::Url; -use uv_client::{is_extended_transient_error, BaseClient, WrappedReqwestError}; +use uv_client::{BaseClient, WrappedReqwestError, is_extended_transient_error}; use uv_distribution_filename::{ExtensionError, SourceDistExtension}; use uv_extract::hash::Hasher; -use uv_fs::{rename_with_retry, Simplified}; +use uv_fs::{Simplified, rename_with_retry}; use uv_pypi_types::{HashAlgorithm, HashDigest}; use uv_static::EnvVars; +use crate::PythonVariant; use crate::implementation::{ Error as ImplementationError, ImplementationName, LenientImplementationName, }; @@ -35,7 +36,6 @@ use crate::installation::PythonInstallationKey; use crate::libc::LibcDetectionError; use crate::managed::ManagedPythonInstallation; use crate::platform::{self, Arch, Libc, Os}; -use crate::PythonVariant; use crate::{Interpreter, PythonRequest, PythonVersion, VersionRequest}; #[derive(Error, Debug)] @@ -88,9 +88,7 @@ pub enum Error { InvalidRequestPlatform(#[from] platform::Error), #[error("No download found for request: {}", _0.green())] NoDownloadFound(PythonDownloadRequest), - #[error( - "A mirror was provided via `{0}`, but the URL does not match the expected format: {0}" - )] + #[error("A mirror was provided via `{0}`, but the URL does not match the expected format: {0}")] Mirror(&'static str, &'static str), #[error(transparent)] LibcDetection(#[from] LibcDetectionError), @@ -1183,7 +1181,7 @@ async fn read_url( let size = response.content_length(); let stream = response .bytes_stream() - .map_err(|err| io::Error::new(io::ErrorKind::Other, err)) + .map_err(io::Error::other) .into_async_read(); Ok((Either::Right(stream.compat()), size)) diff --git a/crates/uv-python/src/environment.rs b/crates/uv-python/src/environment.rs index 959fe150c..de6cf59d8 100644 --- a/crates/uv-python/src/environment.rs +++ b/crates/uv-python/src/environment.rs @@ -14,7 +14,7 @@ use uv_pep440::Version; use crate::discovery::find_python_installation; use crate::installation::PythonInstallation; -use crate::virtualenv::{virtualenv_python_executable, PyVenvConfiguration}; +use crate::virtualenv::{PyVenvConfiguration, virtualenv_python_executable}; use crate::{ EnvironmentPreference, Error, Interpreter, Prefix, PythonNotFound, PythonPreference, PythonRequest, Target, diff --git a/crates/uv-python/src/installation.rs b/crates/uv-python/src/installation.rs index b72f1d87e..9d558f3ff 100644 --- a/crates/uv-python/src/installation.rs +++ b/crates/uv-python/src/installation.rs @@ -8,15 +8,15 @@ use uv_client::BaseClientBuilder; use uv_pep440::{Prerelease, Version}; use crate::discovery::{ - find_best_python_installation, find_python_installation, EnvironmentPreference, PythonRequest, + EnvironmentPreference, PythonRequest, find_best_python_installation, find_python_installation, }; use crate::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequest, Reporter}; use crate::implementation::LenientImplementationName; use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations}; use crate::platform::{Arch, Libc, Os}; use crate::{ - downloads, Error, ImplementationName, Interpreter, PythonDownloads, PythonPreference, - PythonSource, PythonVariant, PythonVersion, + Error, ImplementationName, Interpreter, PythonDownloads, PythonPreference, PythonSource, + PythonVariant, PythonVersion, downloads, }; /// A Python interpreter and accompanying tools. diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 6a6445f9f..2f85fa042 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -17,7 +17,7 @@ use tracing::{debug, trace, warn}; use uv_cache::{Cache, CacheBucket, CachedByTimestamp, Freshness}; use uv_cache_info::Timestamp; use uv_cache_key::cache_digest; -use uv_fs::{write_atomic_sync, PythonExt, Simplified}; +use uv_fs::{PythonExt, Simplified, write_atomic_sync}; use uv_install_wheel::Layout; use uv_pep440::Version; use uv_pep508::{MarkerEnvironment, StringVersion}; @@ -1066,10 +1066,7 @@ fn find_base_python( if let Some(parent) = executable.parent() { parent.join(resolved) } else { - return Err(io::Error::new( - io::ErrorKind::Other, - "Symlink has no parent directory", - )); + return Err(io::Error::other("Symlink has no parent directory")); } } else { resolved diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index 951d41d45..024cd5cbc 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -5,8 +5,9 @@ use thiserror::Error; use uv_static::EnvVars; pub use crate::discovery::{ - find_python_installations, EnvironmentPreference, Error as DiscoveryError, PythonDownloads, - PythonNotFound, PythonPreference, PythonRequest, PythonSource, PythonVariant, VersionRequest, + EnvironmentPreference, Error as DiscoveryError, PythonDownloads, PythonNotFound, + PythonPreference, PythonRequest, PythonSource, PythonVariant, VersionRequest, + find_python_installations, }; pub use crate::environment::{InvalidEnvironmentKind, PythonEnvironment}; pub use crate::implementation::ImplementationName; @@ -18,7 +19,7 @@ pub use crate::python_version::PythonVersion; pub use crate::target::Target; pub use crate::version_files::{ DiscoveryOptions as VersionFileDiscoveryOptions, FilePreference as VersionFilePreference, - PythonVersionFile, PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME, + PYTHON_VERSION_FILENAME, PYTHON_VERSIONS_FILENAME, PythonVersionFile, }; pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment}; @@ -109,7 +110,7 @@ mod tests { }; use anyhow::Result; - use assert_fs::{fixture::ChildPath, prelude::*, TempDir}; + use assert_fs::{TempDir, fixture::ChildPath, prelude::*}; use indoc::{formatdoc, indoc}; use temp_env::with_vars; use test_log::test; @@ -118,15 +119,15 @@ mod tests { use uv_cache::Cache; use crate::{ - discovery::{ - self, find_best_python_installation, find_python_installation, EnvironmentPreference, - }, - PythonPreference, - }; - use crate::{ + PythonNotFound, PythonRequest, PythonSource, PythonVersion, implementation::ImplementationName, installation::PythonInstallation, managed::ManagedPythonInstallations, virtualenv::virtualenv_python_executable, - PythonNotFound, PythonRequest, PythonSource, PythonVersion, + }; + use crate::{ + PythonPreference, + discovery::{ + self, EnvironmentPreference, find_best_python_installation, find_python_installation, + }, }; struct TestContext { diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index 14bdfa8ab..acdeb4e46 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -11,10 +11,10 @@ use same_file::is_same_file; use thiserror::Error; use tracing::{debug, warn}; -use uv_fs::{symlink_or_copy_file, LockedFile, Simplified}; +use uv_fs::{LockedFile, Simplified, symlink_or_copy_file}; use uv_state::{StateBucket, StateStore}; use uv_static::EnvVars; -use uv_trampoline_builder::{windows_python_launcher, Launcher}; +use uv_trampoline_builder::{Launcher, windows_python_launcher}; use crate::downloads::{Error as DownloadError, ManagedPythonDownload}; use crate::implementation::{ @@ -25,7 +25,7 @@ use crate::libc::LibcDetectionError; use crate::platform::Error as PlatformError; use crate::platform::{Arch, Libc, Os}; use crate::python_version::PythonVersion; -use crate::{macos_dylib, sysconfig, PythonRequest, PythonVariant}; +use crate::{PythonRequest, PythonVariant, macos_dylib, sysconfig}; #[derive(Error, Debug)] pub enum Error { diff --git a/crates/uv-python/src/microsoft_store.rs b/crates/uv-python/src/microsoft_store.rs index 3709f54f1..d81b78676 100644 --- a/crates/uv-python/src/microsoft_store.rs +++ b/crates/uv-python/src/microsoft_store.rs @@ -3,8 +3,8 @@ //! //! Effectively a port of -use crate::windows_registry::WindowsPython; use crate::PythonVersion; +use crate::windows_registry::WindowsPython; use itertools::Either; use std::env; use std::path::PathBuf; diff --git a/crates/uv-python/src/platform.rs b/crates/uv-python/src/platform.rs index 77f1b8358..0e64a0fea 100644 --- a/crates/uv-python/src/platform.rs +++ b/crates/uv-python/src/platform.rs @@ -1,5 +1,5 @@ use crate::cpuinfo::detect_hardware_floating_point_support; -use crate::libc::{detect_linux_libc, LibcDetectionError, LibcVersion}; +use crate::libc::{LibcDetectionError, LibcVersion, detect_linux_libc}; use std::fmt::Display; use std::ops::Deref; use std::{fmt, str::FromStr}; diff --git a/crates/uv-python/src/sysconfig/mod.rs b/crates/uv-python/src/sysconfig/mod.rs index 211b15e7d..822408024 100644 --- a/crates/uv-python/src/sysconfig/mod.rs +++ b/crates/uv-python/src/sysconfig/mod.rs @@ -374,11 +374,7 @@ fn patch_pkgconfig(contents: &str) -> Option { Cow::Owned(format!("{prefix}=${{pcfiledir}}/../..")) }) .join("\n"); - if changed { - Some(new_contents) - } else { - None - } + if changed { Some(new_contents) } else { None } } #[derive(thiserror::Error, Debug)] diff --git a/crates/uv-python/src/windows_registry.rs b/crates/uv-python/src/windows_registry.rs index c326c86af..69e179bbf 100644 --- a/crates/uv-python/src/windows_registry.rs +++ b/crates/uv-python/src/windows_registry.rs @@ -2,7 +2,7 @@ use crate::managed::ManagedPythonInstallation; use crate::platform::Arch; -use crate::{PythonInstallationKey, PythonVersion, COMPANY_DISPLAY_NAME, COMPANY_KEY}; +use crate::{COMPANY_DISPLAY_NAME, COMPANY_KEY, PythonInstallationKey, PythonVersion}; use std::cmp::Ordering; use std::collections::HashSet; use std::path::PathBuf; @@ -11,7 +11,7 @@ use target_lexicon::PointerWidth; use thiserror::Error; use tracing::debug; use uv_warnings::{warn_user, warn_user_once}; -use windows_registry::{Key, Value, CURRENT_USER, HSTRING, LOCAL_MACHINE}; +use windows_registry::{CURRENT_USER, HSTRING, Key, LOCAL_MACHINE, Value}; use windows_result::HRESULT; use windows_sys::Win32::Foundation::ERROR_FILE_NOT_FOUND; use windows_sys::Win32::System::Registry::{KEY_WOW64_32KEY, KEY_WOW64_64KEY}; diff --git a/crates/uv-requirements-txt/src/lib.rs b/crates/uv-requirements-txt/src/lib.rs index 78b76496b..439e6f547 100644 --- a/crates/uv-requirements-txt/src/lib.rs +++ b/crates/uv-requirements-txt/src/lib.rs @@ -52,7 +52,7 @@ use uv_distribution_types::{ Requirement, UnresolvedRequirement, UnresolvedRequirementSpecification, }; use uv_fs::Simplified; -use uv_pep508::{expand_env_vars, Pep508Error, RequirementOrigin, VerbatimUrl}; +use uv_pep508::{Pep508Error, RequirementOrigin, VerbatimUrl, expand_env_vars}; use uv_pypi_types::VerbatimParsedUrl; use crate::requirement::EditableError; @@ -1366,7 +1366,7 @@ mod test { use uv_client::BaseClientBuilder; use uv_fs::Simplified; - use crate::{calculate_row_column, RequirementsTxt}; + use crate::{RequirementsTxt, calculate_row_column}; fn workspace_test_data_dir() -> PathBuf { Path::new("./test-data").simple_canonicalize().unwrap() diff --git a/crates/uv-requirements/src/extras.rs b/crates/uv-requirements/src/extras.rs index 140627e5b..87703a98b 100644 --- a/crates/uv-requirements/src/extras.rs +++ b/crates/uv-requirements/src/extras.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use futures::{stream::FuturesOrdered, TryStreamExt}; +use futures::{TryStreamExt, stream::FuturesOrdered}; use uv_distribution::{DistributionDatabase, Reporter}; use uv_distribution_types::DistributionMetadata; @@ -8,7 +8,7 @@ use uv_distribution_types::Requirement; use uv_resolver::{InMemoryIndex, MetadataResponse}; use uv_types::{BuildContext, HashStrategy}; -use crate::{required_dist, Error}; +use crate::{Error, required_dist}; /// A resolver to expand the requested extras for a set of requirements to include all defined /// extras. @@ -55,7 +55,7 @@ impl<'a, Context: BuildContext> ExtrasResolver<'a, Context> { database, } = self; requirements - .map(|requirement| async { + .map(async |requirement| { Self::resolve_requirement(requirement, hasher, index, &database).await }) .collect::>() diff --git a/crates/uv-requirements/src/lookahead.rs b/crates/uv-requirements/src/lookahead.rs index 6033f1b98..44136bdcd 100644 --- a/crates/uv-requirements/src/lookahead.rs +++ b/crates/uv-requirements/src/lookahead.rs @@ -1,7 +1,7 @@ use std::{collections::VecDeque, sync::Arc}; -use futures::stream::FuturesUnordered; use futures::StreamExt; +use futures::stream::FuturesUnordered; use rustc_hash::FxHashSet; use tracing::trace; @@ -11,7 +11,7 @@ use uv_distribution_types::{Dist, DistributionMetadata, Requirement, Requirement use uv_resolver::{InMemoryIndex, MetadataResponse, ResolverEnvironment}; use uv_types::{BuildContext, HashStrategy, RequestedRequirements}; -use crate::{required_dist, Error}; +use crate::{Error, required_dist}; /// A resolver for resolving lookahead requirements from direct URLs. /// diff --git a/crates/uv-requirements/src/source_tree.rs b/crates/uv-requirements/src/source_tree.rs index 3560254a0..4e7ab2b47 100644 --- a/crates/uv-requirements/src/source_tree.rs +++ b/crates/uv-requirements/src/source_tree.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use std::{borrow::Cow, collections::BTreeMap}; use anyhow::{Context, Result}; -use futures::stream::FuturesOrdered; use futures::TryStreamExt; +use futures::stream::FuturesOrdered; use url::Url; use uv_configuration::{DependencyGroups, ExtrasSpecification}; @@ -79,7 +79,7 @@ impl<'a, Context: BuildContext> SourceTreeResolver<'a, Context> { source_trees: impl Iterator, ) -> Result> { let resolutions: Vec<_> = source_trees - .map(|source_tree| async { self.resolve_source_tree(source_tree).await }) + .map(async |source_tree| self.resolve_source_tree(source_tree).await) .collect::>() .try_collect() .await?; diff --git a/crates/uv-requirements/src/sources.rs b/crates/uv-requirements/src/sources.rs index cb932a19e..090a72e5c 100644 --- a/crates/uv-requirements/src/sources.rs +++ b/crates/uv-requirements/src/sources.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use console::Term; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; use uv_requirements_txt::RequirementsTxtRequirement; #[derive(Debug, Clone)] diff --git a/crates/uv-requirements/src/specification.rs b/crates/uv-requirements/src/specification.rs index 1db8533a4..a0b122de8 100644 --- a/crates/uv-requirements/src/specification.rs +++ b/crates/uv-requirements/src/specification.rs @@ -42,7 +42,7 @@ use uv_distribution_types::{ IndexUrl, NameRequirementSpecification, UnresolvedRequirement, UnresolvedRequirementSpecification, }; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_requirements_txt::{RequirementsTxt, RequirementsTxtRequirement}; use uv_warnings::warn_user; diff --git a/crates/uv-requirements/src/unnamed.rs b/crates/uv-requirements/src/unnamed.rs index d58e20a18..c65884315 100644 --- a/crates/uv-requirements/src/unnamed.rs +++ b/crates/uv-requirements/src/unnamed.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use std::sync::Arc; use configparser::ini::Ini; -use futures::{stream::FuturesOrdered, TryStreamExt}; +use futures::{TryStreamExt, stream::FuturesOrdered}; use serde::Deserialize; use tracing::debug; use url::Host; @@ -68,7 +68,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> { database, } = self; requirements - .map(|requirement| async { + .map(async |requirement| { Self::resolve_requirement(requirement, hasher, index, &database) .await .map(Requirement::from) diff --git a/crates/uv-resolver/src/candidate_selector.rs b/crates/uv-resolver/src/candidate_selector.rs index c23a92524..b0fe74409 100644 --- a/crates/uv-resolver/src/candidate_selector.rs +++ b/crates/uv-resolver/src/candidate_selector.rs @@ -125,8 +125,7 @@ impl CandidateSelector { if let Some(installed) = installed { trace!( "Using installed {} {} that satisfies {range}", - installed.name, - installed.version + installed.name, installed.version ); return Some(installed); } @@ -150,8 +149,7 @@ impl CandidateSelector { }) { trace!( "Using installed {} {} that satisfies {range}", - installed.name, - installed.version + installed.name, installed.version ); return Some(installed); } diff --git a/crates/uv-resolver/src/error.rs b/crates/uv-resolver/src/error.rs index e6cf70ece..e3bb9cf23 100644 --- a/crates/uv-resolver/src/error.rs +++ b/crates/uv-resolver/src/error.rs @@ -100,7 +100,7 @@ pub enum ResolveError { ), #[error(transparent)] - NoSolution(#[from] NoSolutionError), + NoSolution(#[from] Box), #[error("Attempted to construct an invalid version specifier")] InvalidVersion(#[from] uv_pep440::VersionSpecifierBuildError), diff --git a/crates/uv-resolver/src/exclude_newer.rs b/crates/uv-resolver/src/exclude_newer.rs index 0702dba46..40ec009f8 100644 --- a/crates/uv-resolver/src/exclude_newer.rs +++ b/crates/uv-resolver/src/exclude_newer.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use jiff::{tz::TimeZone, Timestamp, ToSpan}; +use jiff::{Timestamp, ToSpan, tz::TimeZone}; /// A timestamp that excludes files newer than it. #[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)] diff --git a/crates/uv-resolver/src/flat_index.rs b/crates/uv-resolver/src/flat_index.rs index 33dc01435..46da6ddbf 100644 --- a/crates/uv-resolver/src/flat_index.rs +++ b/crates/uv-resolver/src/flat_index.rs @@ -1,5 +1,5 @@ -use std::collections::btree_map::Entry; use std::collections::BTreeMap; +use std::collections::btree_map::Entry; use rustc_hash::FxHashMap; use tracing::instrument; diff --git a/crates/uv-resolver/src/fork_indexes.rs b/crates/uv-resolver/src/fork_indexes.rs index bb2045bab..5b39fb626 100644 --- a/crates/uv-resolver/src/fork_indexes.rs +++ b/crates/uv-resolver/src/fork_indexes.rs @@ -2,8 +2,8 @@ use rustc_hash::FxHashMap; use uv_distribution_types::IndexMetadata; use uv_normalize::PackageName; -use crate::resolver::ResolverEnvironment; use crate::ResolveError; +use crate::resolver::ResolverEnvironment; /// See [`crate::resolver::ForkState`]. #[derive(Default, Debug, Clone)] diff --git a/crates/uv-resolver/src/fork_urls.rs b/crates/uv-resolver/src/fork_urls.rs index f9629be53..dc1b067c4 100644 --- a/crates/uv-resolver/src/fork_urls.rs +++ b/crates/uv-resolver/src/fork_urls.rs @@ -6,8 +6,8 @@ use uv_distribution_types::Verbatim; use uv_normalize::PackageName; use uv_pypi_types::VerbatimParsedUrl; -use crate::resolver::ResolverEnvironment; use crate::ResolveError; +use crate::resolver::ResolverEnvironment; /// See [`crate::resolver::ForkState`]. #[derive(Default, Debug, Clone)] diff --git a/crates/uv-resolver/src/lock/export/mod.rs b/crates/uv-resolver/src/lock/export/mod.rs index 3a52d7c06..5b69329a7 100644 --- a/crates/uv-resolver/src/lock/export/mod.rs +++ b/crates/uv-resolver/src/lock/export/mod.rs @@ -1,5 +1,5 @@ -use std::collections::hash_map::Entry; use std::collections::VecDeque; +use std::collections::hash_map::Entry; use either::Either; use petgraph::graph::NodeIndex; @@ -15,7 +15,7 @@ use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_pep508::MarkerTree; use uv_pypi_types::ConflictItem; -use crate::graph_ops::{marker_reachability, Reachable}; +use crate::graph_ops::{Reachable, marker_reachability}; pub(crate) use crate::lock::export::pylock_toml::PylockTomlPackage; pub use crate::lock::export::pylock_toml::{PylockToml, PylockTomlErrorKind}; pub use crate::lock::export::requirements_txt::RequirementsTxtExport; diff --git a/crates/uv-resolver/src/lock/export/pylock_toml.rs b/crates/uv-resolver/src/lock/export/pylock_toml.rs index 815f7687a..1ab2ce152 100644 --- a/crates/uv-resolver/src/lock/export/pylock_toml.rs +++ b/crates/uv-resolver/src/lock/export/pylock_toml.rs @@ -4,11 +4,11 @@ use std::path::Path; use std::str::FromStr; use std::sync::Arc; +use jiff::Timestamp; use jiff::civil::{Date, DateTime, Time}; use jiff::tz::{Offset, TimeZone}; -use jiff::Timestamp; use serde::Deserialize; -use toml_edit::{value, Array, ArrayOfTables, Item, Table}; +use toml_edit::{Array, ArrayOfTables, Item, Table, value}; use url::Url; use uv_cache_key::RepositoryUrl; @@ -25,7 +25,7 @@ use uv_distribution_types::{ RegistryBuiltDist, RegistryBuiltWheel, RegistrySourceDist, RemoteSource, Resolution, ResolvedDist, SourceDist, ToUrlError, UrlString, }; -use uv_fs::{relative_to, PortablePathBuf}; +use uv_fs::{PortablePathBuf, relative_to}; use uv_git::{RepositoryReference, ResolvedRepositoryReference}; use uv_git_types::{GitOid, GitReference, GitUrl, GitUrlParseError}; use uv_normalize::{ExtraName, GroupName, PackageName}; @@ -36,7 +36,7 @@ use uv_pypi_types::{HashDigests, Hashes, ParsedGitUrl, VcsKind}; use uv_small_str::SmallString; use crate::lock::export::ExportableRequirements; -use crate::lock::{each_element_on_its_line_array, Source, WheelTagHint}; +use crate::lock::{Source, WheelTagHint, each_element_on_its_line_array}; use crate::resolution::ResolutionGraphNode; use crate::{Installable, LockError, RequiresPython, ResolverOutput}; @@ -1102,11 +1102,10 @@ impl<'lock> PylockToml { hashes, install: true, } - } else if let Some(dist) = - package - .archive - .as_ref() - .filter(|_| if is_wheel { !no_binary } else { !no_build }) + } else if let Some(dist) = package + .archive + .as_ref() + .filter(|_| if is_wheel { !no_binary } else { !no_build }) { let hashes = HashDigests::from(dist.hashes.clone()); let dist = dist.to_dist(install_path, &package.name, package.version.as_ref())?; diff --git a/crates/uv-resolver/src/lock/installable.rs b/crates/uv-resolver/src/lock/installable.rs index c5bf9f59a..4522a243d 100644 --- a/crates/uv-resolver/src/lock/installable.rs +++ b/crates/uv-resolver/src/lock/installable.rs @@ -1,6 +1,6 @@ -use std::collections::hash_map::Entry; use std::collections::BTreeSet; use std::collections::VecDeque; +use std::collections::hash_map::Entry; use std::path::Path; use std::sync::Arc; @@ -468,10 +468,7 @@ pub trait Installable<'lock> { entry.insert(index); index } - Entry::Occupied(entry) => { - let index = *entry.get(); - index - } + Entry::Occupied(entry) => *entry.get(), }; // Add the edge. diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index 331194054..6dab3b4b1 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -15,7 +15,7 @@ use petgraph::graph::NodeIndex; use petgraph::visit::EdgeRef; use rustc_hash::{FxHashMap, FxHashSet}; use serde::Serializer; -use toml_edit::{value, Array, ArrayOfTables, InlineTable, Item, Table, Value}; +use toml_edit::{Array, ArrayOfTables, InlineTable, Item, Table, Value, value}; use tracing::debug; use url::Url; @@ -26,18 +26,18 @@ use uv_distribution_filename::{ BuildTag, DistExtension, ExtensionError, SourceDistExtension, WheelFilename, }; use uv_distribution_types::{ - redact_credentials, BuiltDist, DependencyMetadata, DirectUrlBuiltDist, DirectUrlSourceDist, - DirectorySourceDist, Dist, DistributionMetadata, FileLocation, GitSourceDist, IndexLocations, - IndexMetadata, IndexUrl, Name, PathBuiltDist, PathSourceDist, RegistryBuiltDist, - RegistryBuiltWheel, RegistrySourceDist, RemoteSource, Requirement, RequirementSource, - ResolvedDist, StaticMetadata, ToUrlError, UrlString, + BuiltDist, DependencyMetadata, DirectUrlBuiltDist, DirectUrlSourceDist, DirectorySourceDist, + Dist, DistributionMetadata, FileLocation, GitSourceDist, IndexLocations, IndexMetadata, + IndexUrl, Name, PathBuiltDist, PathSourceDist, RegistryBuiltDist, RegistryBuiltWheel, + RegistrySourceDist, RemoteSource, Requirement, RequirementSource, ResolvedDist, StaticMetadata, + ToUrlError, UrlString, redact_credentials, }; -use uv_fs::{relative_to, PortablePath, PortablePathBuf}; +use uv_fs::{PortablePath, PortablePathBuf, relative_to}; use uv_git::{RepositoryReference, ResolvedRepositoryReference}; use uv_git_types::{GitOid, GitReference, GitUrl, GitUrlParseError}; use uv_normalize::{ExtraName, GroupName, PackageName}; use uv_pep440::Version; -use uv_pep508::{split_scheme, MarkerEnvironment, MarkerTree, VerbatimUrl, VerbatimUrlError}; +use uv_pep508::{MarkerEnvironment, MarkerTree, VerbatimUrl, VerbatimUrlError, split_scheme}; use uv_platform_tags::{ AbiTag, IncompatibleTag, LanguageTag, PlatformTag, TagCompatibility, TagPriority, Tags, }; @@ -1100,8 +1100,8 @@ impl Lock { fn find_by_id(&self, id: &PackageId) -> &Package { let index = *self.by_id.get(id).expect("locked package for ID"); - let dist = self.packages.get(index).expect("valid index for package"); - dist + + (self.packages.get(index).expect("valid index for package")) as _ } /// Return a [`SatisfiesResult`] if the given extras do not match the [`Package`] metadata. diff --git a/crates/uv-resolver/src/requires_python.rs b/crates/uv-resolver/src/requires_python.rs index f105c8680..8e4d33213 100644 --- a/crates/uv-resolver/src/requires_python.rs +++ b/crates/uv-resolver/src/requires_python.rs @@ -4,8 +4,8 @@ use pubgrub::Range; use uv_distribution_filename::WheelFilename; use uv_pep440::{ - release_specifiers_to_ranges, LowerBound, UpperBound, Version, VersionSpecifier, - VersionSpecifiers, + LowerBound, UpperBound, Version, VersionSpecifier, VersionSpecifiers, + release_specifiers_to_ranges, }; use uv_pep508::{MarkerExpression, MarkerTree, MarkerValueVersion}; use uv_platform_tags::{AbiTag, LanguageTag}; @@ -821,16 +821,20 @@ mod tests { // Splitting `>=3.10` on `>=3.9` should return `None`. let version_specifiers = VersionSpecifiers::from_str(">=3.10").unwrap(); let requires_python = RequiresPython::from_specifiers(&version_specifiers); - assert!(requires_python - .split(Bound::Included(Version::new([3, 9]))) - .is_none()); + assert!( + requires_python + .split(Bound::Included(Version::new([3, 9]))) + .is_none() + ); // Splitting `>=3.10` on `>=3.10` should return `None`. let version_specifiers = VersionSpecifiers::from_str(">=3.10").unwrap(); let requires_python = RequiresPython::from_specifiers(&version_specifiers); - assert!(requires_python - .split(Bound::Included(Version::new([3, 10]))) - .is_none()); + assert!( + requires_python + .split(Bound::Included(Version::new([3, 10]))) + .is_none() + ); // Splitting `>=3.9, <3.13` on `>=3.11` should result in `>=3.9, <3.11` and `>=3.11, <3.13`. let version_specifiers = VersionSpecifiers::from_str(">=3.9, <3.13").unwrap(); diff --git a/crates/uv-resolver/src/resolution/output.rs b/crates/uv-resolver/src/resolution/output.rs index 81f48692b..5df5ae6c3 100644 --- a/crates/uv-resolver/src/resolution/output.rs +++ b/crates/uv-resolver/src/resolution/output.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use indexmap::IndexSet; use petgraph::{ - graph::{Graph, NodeIndex}, Directed, Direction, + graph::{Graph, NodeIndex}, }; use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet}; @@ -60,6 +60,7 @@ pub struct ResolverOutput { } #[derive(Debug, Clone)] +#[allow(clippy::large_enum_variant)] pub(crate) enum ResolutionGraphNode { Root, Dist(AnnotatedDist), diff --git a/crates/uv-resolver/src/resolution/requirements_txt.rs b/crates/uv-resolver/src/resolution/requirements_txt.rs index 3a9cb1ace..5ad6480c2 100644 --- a/crates/uv-resolver/src/resolution/requirements_txt.rs +++ b/crates/uv-resolver/src/resolution/requirements_txt.rs @@ -7,7 +7,7 @@ use itertools::Itertools; use uv_distribution_types::{DistributionMetadata, Name, ResolvedDist, Verbatim, VersionOrUrlRef}; use uv_normalize::{ExtraName, PackageName}; use uv_pep440::Version; -use uv_pep508::{split_scheme, MarkerTree, Scheme}; +use uv_pep508::{MarkerTree, Scheme, split_scheme}; use uv_pypi_types::HashDigest; use crate::{ diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 1bcd6ddc7..0194611d4 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -18,7 +18,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::oneshot; use tokio_stream::wrappers::ReceiverStream; -use tracing::{debug, info, instrument, trace, warn, Level}; +use tracing::{Level, debug, info, instrument, trace, warn}; use uv_configuration::{Constraints, Overrides}; use uv_distribution::DistributionDatabase; @@ -30,7 +30,7 @@ use uv_distribution_types::{ }; use uv_git::GitResolver; use uv_normalize::{ExtraName, GroupName, PackageName}; -use uv_pep440::{release_specifiers_to_ranges, Version, VersionSpecifiers, MIN_VERSION}; +use uv_pep440::{MIN_VERSION, Version, VersionSpecifiers, release_specifiers_to_ranges}; use uv_pep508::{MarkerExpression, MarkerOperator, MarkerTree, MarkerValueString}; use uv_platform_tags::Tags; use uv_pypi_types::{ConflictItem, ConflictItemRef, Conflicts, VerbatimParsedUrl}; @@ -60,7 +60,7 @@ use crate::resolver::batch_prefetch::BatchPrefetcher; pub use crate::resolver::derivation::DerivationChainBuilder; pub use crate::resolver::environment::ResolverEnvironment; use crate::resolver::environment::{ - fork_version_by_marker, fork_version_by_python_requirement, ForkingPossibility, + ForkingPossibility, fork_version_by_marker, fork_version_by_python_requirement, }; pub(crate) use crate::resolver::fork_map::{ForkMap, ForkSet}; pub use crate::resolver::index::InMemoryIndex; @@ -74,7 +74,7 @@ use crate::resolver::system::SystemDependency; pub(crate) use crate::resolver::urls::Urls; use crate::universal_marker::{ConflictMarker, UniversalMarker}; use crate::yanks::AllowedYanks; -use crate::{marker, DependencyMode, Exclusions, FlatIndex, Options, ResolutionMode, VersionMap}; +use crate::{DependencyMode, Exclusions, FlatIndex, Options, ResolutionMode, VersionMap, marker}; pub(crate) use provider::MetadataUnavailable; use uv_torch::TorchStrategy; @@ -2575,7 +2575,7 @@ impl ResolverState ResolverState ResolverProvider for DefaultResolverProvider<'_, Con } /// Set the [`Reporter`] to use for this installer. - #[must_use] fn with_reporter(self, reporter: Arc) -> Self { Self { fetcher: self.fetcher.with_reporter(reporter), diff --git a/crates/uv-resolver/src/version_map.rs b/crates/uv-resolver/src/version_map.rs index 7176a5b13..44e70e73b 100644 --- a/crates/uv-resolver/src/version_map.rs +++ b/crates/uv-resolver/src/version_map.rs @@ -1,5 +1,5 @@ -use std::collections::btree_map::{BTreeMap, Entry}; use std::collections::Bound; +use std::collections::btree_map::{BTreeMap, Entry}; use std::ops::RangeBounds; use std::sync::OnceLock; @@ -21,7 +21,7 @@ use uv_types::HashStrategy; use uv_warnings::warn_user_once; use crate::flat_index::FlatDistributions; -use crate::{yanks::AllowedYanks, ExcludeNewer, RequiresPython}; +use crate::{ExcludeNewer, RequiresPython, yanks::AllowedYanks}; /// A map from versions to distributions. #[derive(Debug)] @@ -309,6 +309,7 @@ impl<'a> VersionMapDistHandle<'a> { /// The kind of internal version map we have. #[derive(Debug)] +#[allow(clippy::large_enum_variant)] enum VersionMapInner { /// All distributions are fully materialized in memory. /// diff --git a/crates/uv-scripts/Cargo.toml b/crates/uv-scripts/Cargo.toml index 2554e6b23..32a6b68b9 100644 --- a/crates/uv-scripts/Cargo.toml +++ b/crates/uv-scripts/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-scripts" version = "0.0.1" -edition = "2021" +edition = { workspace = true } description = "Parse PEP 723-style Python scripts." [lib] diff --git a/crates/uv-scripts/src/lib.rs b/crates/uv-scripts/src/lib.rs index 2a530435a..5f169f126 100644 --- a/crates/uv-scripts/src/lib.rs +++ b/crates/uv-scripts/src/lib.rs @@ -370,7 +370,9 @@ pub struct ToolUv { #[derive(Debug, Error)] pub enum Pep723Error { - #[error("An opening tag (`# /// script`) was found without a closing tag (`# ///`). Ensure that every line between the opening and closing tags (including empty lines) starts with a leading `#`.")] + #[error( + "An opening tag (`# /// script`) was found without a closing tag (`# ///`). Ensure that every line between the opening and closing tags (including empty lines) starts with a leading `#`." + )] UnclosedBlock, #[error("The PEP 723 metadata block is missing from the script.")] MissingTag, @@ -585,7 +587,7 @@ fn serialize_metadata(metadata: &str) -> String { #[cfg(test)] mod tests { - use crate::{serialize_metadata, Pep723Error, Pep723Script, ScriptTag}; + use crate::{Pep723Error, Pep723Script, ScriptTag, serialize_metadata}; use std::str::FromStr; #[test] diff --git a/crates/uv-shell/Cargo.toml b/crates/uv-shell/Cargo.toml index 7e03328ec..efc73a42e 100644 --- a/crates/uv-shell/Cargo.toml +++ b/crates/uv-shell/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uv-shell" version = "0.0.1" -edition = "2021" +edition = { workspace = true } description = "Utilities for detecting and manipulating shell environments" [lib] diff --git a/crates/uv-state/src/lib.rs b/crates/uv-state/src/lib.rs index 90c930ccc..2fd663b7f 100644 --- a/crates/uv-state/src/lib.rs +++ b/crates/uv-state/src/lib.rs @@ -5,7 +5,7 @@ use std::{ }; use fs_err as fs; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; /// The main state storage abstraction. /// diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index a7a7cfb1b..f85075ea6 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -414,13 +414,10 @@ pub fn entrypoint_paths( let layout = site_packages.interpreter().layout(); let script_relative = pathdiff::diff_paths(&layout.scheme.scripts, &layout.scheme.purelib) .ok_or_else(|| { - io::Error::new( - io::ErrorKind::Other, - format!( - "Could not find relative path for: {}", - layout.scheme.scripts.simplified_display() - ), - ) + io::Error::other(format!( + "Could not find relative path for: {}", + layout.scheme.scripts.simplified_display() + )) })?; // Identify any installed binaries (both entrypoints and scripts from the `.data` directory). diff --git a/crates/uv-tool/src/tool.rs b/crates/uv-tool/src/tool.rs index a89aeb98c..df8571c94 100644 --- a/crates/uv-tool/src/tool.rs +++ b/crates/uv-tool/src/tool.rs @@ -2,7 +2,7 @@ use std::fmt::{self, Display, Formatter}; use std::path::PathBuf; use serde::Deserialize; -use toml_edit::{value, Array, Item, Table, Value}; +use toml_edit::{Array, Item, Table, Value, value}; use uv_distribution_types::Requirement; use uv_fs::{PortablePath, Simplified}; diff --git a/crates/uv-trampoline-builder/src/lib.rs b/crates/uv-trampoline-builder/src/lib.rs index 21fc69050..15b435ec5 100644 --- a/crates/uv-trampoline-builder/src/lib.rs +++ b/crates/uv-trampoline-builder/src/lib.rs @@ -5,8 +5,8 @@ use std::str::Utf8Error; use fs_err::File; use thiserror::Error; use uv_fs::Simplified; -use zip::write::SimpleFileOptions; use zip::ZipWriter; +use zip::write::SimpleFileOptions; #[cfg(all(windows, target_arch = "x86"))] const LAUNCHER_I686_GUI: &[u8] = @@ -324,7 +324,7 @@ mod test { use which::which; - use super::{windows_python_launcher, windows_script_launcher, Launcher, LauncherKind}; + use super::{Launcher, LauncherKind, windows_python_launcher, windows_script_launcher}; #[test] #[cfg(all(windows, target_arch = "x86", feature = "production"))] diff --git a/crates/uv-trampoline/Cargo.toml b/crates/uv-trampoline/Cargo.toml index 1e1d78e17..718c7e3f9 100644 --- a/crates/uv-trampoline/Cargo.toml +++ b/crates/uv-trampoline/Cargo.toml @@ -3,7 +3,7 @@ name = "uv-trampoline" version = "0.1.0" authors = ["Nathaniel J. Smith "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/crates/uv-trampoline/src/bin/uv-trampoline-console.rs b/crates/uv-trampoline/src/bin/uv-trampoline-console.rs index 09af4a728..b4c540a07 100644 --- a/crates/uv-trampoline/src/bin/uv-trampoline-console.rs +++ b/crates/uv-trampoline/src/bin/uv-trampoline-console.rs @@ -3,7 +3,7 @@ // Named according to https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol // This avoids having to define a custom /ENTRY:entry_fn in build.rs -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn mainCRTStartup() -> ! { uv_trampoline::bounce::bounce(false) } diff --git a/crates/uv-trampoline/src/bin/uv-trampoline-gui.rs b/crates/uv-trampoline/src/bin/uv-trampoline-gui.rs index 28ac04265..efba4e78d 100644 --- a/crates/uv-trampoline/src/bin/uv-trampoline-gui.rs +++ b/crates/uv-trampoline/src/bin/uv-trampoline-gui.rs @@ -3,7 +3,7 @@ // Named according to https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol // This avoids having to define a custom /ENTRY:entry_fn in build.rs -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn mainCRTStartup() -> ! { uv_trampoline::bounce::bounce(true) } diff --git a/crates/uv-virtualenv/src/virtualenv.rs b/crates/uv-virtualenv/src/virtualenv.rs index 498ae4246..a641e5541 100644 --- a/crates/uv-virtualenv/src/virtualenv.rs +++ b/crates/uv-virtualenv/src/virtualenv.rs @@ -10,7 +10,7 @@ use fs_err::File; use itertools::Itertools; use tracing::debug; -use uv_fs::{cachedir, Simplified, CWD}; +use uv_fs::{CWD, Simplified, cachedir}; use uv_pypi_types::Scheme; use uv_python::{Interpreter, VirtualEnvironment}; use uv_shell::escape_posix_for_single_quotes; diff --git a/crates/uv-workspace/src/dependency_groups.rs b/crates/uv-workspace/src/dependency_groups.rs index 3f1d1f94d..e6964544a 100644 --- a/crates/uv-workspace/src/dependency_groups.rs +++ b/crates/uv-workspace/src/dependency_groups.rs @@ -1,11 +1,11 @@ -use std::collections::btree_map::Entry; use std::collections::BTreeMap; +use std::collections::btree_map::Entry; use std::str::FromStr; use thiserror::Error; use tracing::error; -use uv_normalize::{GroupName, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, GroupName}; use uv_pep508::Pep508Error; use uv_pypi_types::{DependencyGroupSpecifier, VerbatimParsedUrl}; diff --git a/crates/uv-workspace/src/pyproject.rs b/crates/uv-workspace/src/pyproject.rs index fab891cd7..4efd322cc 100644 --- a/crates/uv-workspace/src/pyproject.rs +++ b/crates/uv-workspace/src/pyproject.rs @@ -15,12 +15,12 @@ use std::str::FromStr; use glob::Pattern; use owo_colors::OwoColorize; use rustc_hash::{FxBuildHasher, FxHashSet}; -use serde::{de::IntoDeserializer, de::SeqAccess, Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Deserializer, Serialize, de::IntoDeserializer, de::SeqAccess}; use thiserror::Error; use url::Url; use uv_build_backend::BuildBackendSettings; use uv_distribution_types::{Index, IndexName, RequirementSource}; -use uv_fs::{relative_to, PortablePathBuf}; +use uv_fs::{PortablePathBuf, relative_to}; use uv_git_types::GitReference; use uv_macros::OptionsMetadata; use uv_normalize::{DefaultGroups, ExtraName, GroupName, PackageName}; diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index 374b9e762..3caaa8f8c 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -4,13 +4,13 @@ use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; -use glob::{glob, GlobError, PatternError}; +use glob::{GlobError, PatternError, glob}; use rustc_hash::{FxHashMap, FxHashSet}; use tracing::{debug, trace, warn}; use uv_distribution_types::{Index, Requirement, RequirementSource}; -use uv_fs::{Simplified, CWD}; -use uv_normalize::{GroupName, PackageName, DEV_DEPENDENCIES}; +use uv_fs::{CWD, Simplified}; +use uv_normalize::{DEV_DEPENDENCIES, GroupName, PackageName}; use uv_pep440::VersionSpecifiers; use uv_pep508::{MarkerTree, VerbatimUrl}; use uv_pypi_types::{Conflicts, SupportedEnvironments, VerbatimParsedUrl}; diff --git a/crates/uv/src/commands/build_frontend.rs b/crates/uv/src/commands/build_frontend.rs index 3d87751c4..c601541da 100644 --- a/crates/uv/src/commands/build_frontend.rs +++ b/crates/uv/src/commands/build_frontend.rs @@ -23,7 +23,7 @@ use uv_distribution_filename::{ DistFilename, SourceDistExtension, SourceDistFilename, WheelFilename, }; use uv_distribution_types::{DependencyMetadata, Index, IndexLocations, SourceDist}; -use uv_fs::{relative_to, Simplified}; +use uv_fs::{Simplified, relative_to}; use uv_install_wheel::LinkMode; use uv_normalize::PackageName; use uv_pep440::Version; @@ -38,10 +38,10 @@ use uv_settings::PythonInstallMirrors; use uv_types::{AnyErrorBuild, BuildContext, BuildIsolation, BuildStack, HashStrategy}; use uv_workspace::{DiscoveryOptions, Workspace, WorkspaceCache, WorkspaceError}; -use crate::commands::pip::operations; -use crate::commands::project::{find_requires_python, ProjectError}; -use crate::commands::reporters::PythonDownloadReporter; use crate::commands::ExitStatus; +use crate::commands::pip::operations; +use crate::commands::project::{ProjectError, find_requires_python}; +use crate::commands::reporters::PythonDownloadReporter; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverSettings}; diff --git a/crates/uv/src/commands/cache_clean.rs b/crates/uv/src/commands/cache_clean.rs index ec6c7e7ca..ef61db57a 100644 --- a/crates/uv/src/commands/cache_clean.rs +++ b/crates/uv/src/commands/cache_clean.rs @@ -8,7 +8,7 @@ use uv_fs::Simplified; use uv_normalize::PackageName; use crate::commands::reporters::{CleaningDirectoryReporter, CleaningPackageReporter}; -use crate::commands::{human_readable_bytes, ExitStatus}; +use crate::commands::{ExitStatus, human_readable_bytes}; use crate::printer::Printer; /// Clear the cache, removing all entries or those linked to specific packages. diff --git a/crates/uv/src/commands/cache_prune.rs b/crates/uv/src/commands/cache_prune.rs index 681236993..ba2241169 100644 --- a/crates/uv/src/commands/cache_prune.rs +++ b/crates/uv/src/commands/cache_prune.rs @@ -6,7 +6,7 @@ use owo_colors::OwoColorize; use uv_cache::{Cache, Removal}; use uv_fs::Simplified; -use crate::commands::{human_readable_bytes, ExitStatus}; +use crate::commands::{ExitStatus, human_readable_bytes}; use crate::printer::Printer; /// Prune all unreachable objects from the cache. diff --git a/crates/uv/src/commands/diagnostics.rs b/crates/uv/src/commands/diagnostics.rs index 5ddff0737..7a9fcbd35 100644 --- a/crates/uv/src/commands/diagnostics.rs +++ b/crates/uv/src/commands/diagnostics.rs @@ -241,7 +241,7 @@ pub(crate) fn no_solution_context(err: &uv_resolver::NoSolutionError, context: & } /// Render a [`uv_resolver::NoSolutionError`] with a help message. -pub(crate) fn no_solution_hint(err: uv_resolver::NoSolutionError, help: String) { +pub(crate) fn no_solution_hint(err: Box, help: String) { #[derive(Debug, miette::Diagnostic, thiserror::Error)] #[error("{header}")] #[diagnostic()] @@ -251,7 +251,7 @@ pub(crate) fn no_solution_hint(err: uv_resolver::NoSolutionError, help: String) /// The underlying error. #[source] - err: uv_resolver::NoSolutionError, + err: Box, /// The help message to display. #[help] diff --git a/crates/uv/src/commands/help.rs b/crates/uv/src/commands/help.rs index e67c8239f..990f53635 100644 --- a/crates/uv/src/commands/help.rs +++ b/crates/uv/src/commands/help.rs @@ -3,8 +3,8 @@ use std::path::PathBuf; use std::str::FromStr; use std::{fmt::Display, fmt::Write}; -use anstream::{stream::IsTerminal, ColorChoice}; -use anyhow::{anyhow, Result}; +use anstream::{ColorChoice, stream::IsTerminal}; +use anyhow::{Result, anyhow}; use clap::CommandFactory; use itertools::{Either, Itertools}; use owo_colors::OwoColorize; diff --git a/crates/uv/src/commands/mod.rs b/crates/uv/src/commands/mod.rs index 27874ac10..8e3c9ef37 100644 --- a/crates/uv/src/commands/mod.rs +++ b/crates/uv/src/commands/mod.rs @@ -23,10 +23,10 @@ pub(crate) use pip::tree::pip_tree; pub(crate) use pip::uninstall::pip_uninstall; pub(crate) use project::add::add; pub(crate) use project::export::export; -pub(crate) use project::init::{init, InitKind, InitProjectKind}; +pub(crate) use project::init::{InitKind, InitProjectKind, init}; pub(crate) use project::lock::lock; pub(crate) use project::remove::remove; -pub(crate) use project::run::{run, RunCommand}; +pub(crate) use project::run::{RunCommand, run}; pub(crate) use project::sync::sync; pub(crate) use project::tree::tree; pub(crate) use publish::publish; @@ -42,15 +42,15 @@ pub(crate) use self_update::self_update; pub(crate) use tool::dir::dir as tool_dir; pub(crate) use tool::install::install as tool_install; pub(crate) use tool::list::list as tool_list; -pub(crate) use tool::run::run as tool_run; pub(crate) use tool::run::ToolRunCommand; +pub(crate) use tool::run::run as tool_run; pub(crate) use tool::uninstall::uninstall as tool_uninstall; pub(crate) use tool::update_shell::update_shell as tool_update_shell; pub(crate) use tool::upgrade::upgrade as tool_upgrade; use uv_cache::Cache; use uv_configuration::Concurrency; use uv_distribution_types::InstalledMetadata; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; use uv_installer::compile_tree; use uv_normalize::PackageName; use uv_python::PythonEnvironment; @@ -295,6 +295,7 @@ pub(super) fn capitalize(s: &str) -> String { /// A Python file that may or may not include an existing PEP 723 script tag. #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub(crate) enum ScriptPath { /// The Python file already includes a PEP 723 script tag. Script(Pep723Script), diff --git a/crates/uv/src/commands/pip/check.rs b/crates/uv/src/commands/pip/check.rs index a53e124a9..f504503af 100644 --- a/crates/uv/src/commands/pip/check.rs +++ b/crates/uv/src/commands/pip/check.rs @@ -10,7 +10,7 @@ use uv_installer::{SitePackages, SitePackagesDiagnostic}; use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest}; use crate::commands::pip::operations::report_target_environment; -use crate::commands::{elapsed, ExitStatus}; +use crate::commands::{ExitStatus, elapsed}; use crate::printer::Printer; /// Check for incompatibilities in installed packages. diff --git a/crates/uv/src/commands/pip/compile.rs b/crates/uv/src/commands/pip/compile.rs index 92f0bc79e..f6e0908d2 100644 --- a/crates/uv/src/commands/pip/compile.rs +++ b/crates/uv/src/commands/pip/compile.rs @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use itertools::Itertools; use owo_colors::OwoColorize; use rustc_hash::FxHashSet; @@ -23,7 +23,7 @@ use uv_distribution_types::{ DependencyMetadata, HashGeneration, Index, IndexLocations, NameRequirementSpecification, Origin, Requirement, UnresolvedRequirementSpecification, Verbatim, }; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; use uv_git::ResolvedRepositoryReference; use uv_install_wheel::LinkMode; use uv_normalize::{GroupName, PackageName}; @@ -32,9 +32,9 @@ use uv_python::{ EnvironmentPreference, PythonEnvironment, PythonInstallation, PythonPreference, PythonRequest, PythonVersion, VersionRequest, }; -use uv_requirements::upgrade::{read_pylock_toml_requirements, LockedRequirements}; +use uv_requirements::upgrade::{LockedRequirements, read_pylock_toml_requirements}; use uv_requirements::{ - is_pylock_toml, upgrade::read_requirements_txt, RequirementsSource, RequirementsSpecification, + RequirementsSource, RequirementsSpecification, is_pylock_toml, upgrade::read_requirements_txt, }; use uv_resolver::{ AnnotationStyle, DependencyMode, DisplayResolutionGraph, ExcludeNewer, FlatIndex, ForkStrategy, @@ -48,7 +48,7 @@ use uv_workspace::WorkspaceCache; use crate::commands::pip::loggers::DefaultResolveLogger; use crate::commands::pip::{operations, resolution_environment}; -use crate::commands::{diagnostics, ExitStatus, OutputWriter}; +use crate::commands::{ExitStatus, OutputWriter, diagnostics}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/pip/freeze.rs b/crates/uv/src/commands/pip/freeze.rs index 260f7b142..7ad5517af 100644 --- a/crates/uv/src/commands/pip/freeze.rs +++ b/crates/uv/src/commands/pip/freeze.rs @@ -10,8 +10,8 @@ use uv_distribution_types::{Diagnostic, InstalledDist, Name}; use uv_installer::SitePackages; use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest}; -use crate::commands::pip::operations::report_target_environment; use crate::commands::ExitStatus; +use crate::commands::pip::operations::report_target_environment; use crate::printer::Printer; /// Enumerate the installed packages in the current environment. diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index 5d39346eb..1cfac27ca 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use anyhow::Context; use itertools::Itertools; use owo_colors::OwoColorize; -use tracing::{debug, enabled, Level}; +use tracing::{Level, debug, enabled}; use uv_cache::Cache; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; @@ -44,7 +44,7 @@ use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger, use crate::commands::pip::operations::Modifications; use crate::commands::pip::operations::{report_interpreter, report_target_environment}; use crate::commands::pip::{operations, resolution_markers, resolution_tags}; -use crate::commands::{diagnostics, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/pip/list.rs b/crates/uv/src/commands/pip/list.rs index 46d66e678..48786d86c 100644 --- a/crates/uv/src/commands/pip/list.rs +++ b/crates/uv/src/commands/pip/list.rs @@ -26,10 +26,10 @@ use uv_python::PythonRequest; use uv_python::{EnvironmentPreference, PythonEnvironment}; use uv_resolver::{ExcludeNewer, PrereleaseMode, RequiresPython}; +use crate::commands::ExitStatus; use crate::commands::pip::latest::LatestClient; use crate::commands::pip::operations::report_target_environment; use crate::commands::reporters::LatestVersionReporter; -use crate::commands::ExitStatus; use crate::printer::Printer; use crate::settings::NetworkSettings; @@ -118,7 +118,7 @@ pub(crate) async fn pip_list( // Fetch the latest version for each package. let mut fetches = futures::stream::iter(&results) - .map(|dist| async { + .map(async |dist| { let latest = client .find_latest(dist.name(), None, &download_concurrency) .await?; diff --git a/crates/uv/src/commands/pip/loggers.rs b/crates/uv/src/commands/pip/loggers.rs index ee88728ad..1f9aaffa5 100644 --- a/crates/uv/src/commands/pip/loggers.rs +++ b/crates/uv/src/commands/pip/loggers.rs @@ -11,7 +11,7 @@ use uv_normalize::PackageName; use uv_pep440::Version; use crate::commands::pip::operations::Changelog; -use crate::commands::{elapsed, ChangeEvent, ChangeEventKind}; +use crate::commands::{ChangeEvent, ChangeEventKind, elapsed}; use crate::printer::Printer; /// A trait to handle logging during install operations. @@ -398,7 +398,7 @@ impl InstallLogger for UpgradeInstallLogger { pub(crate) trait ResolveLogger { /// Log the completion of the operation. fn on_complete(&self, count: usize, start: std::time::Instant, printer: Printer) - -> fmt::Result; + -> fmt::Result; } /// The default logger for resolve operations. diff --git a/crates/uv/src/commands/pip/operations.rs b/crates/uv/src/commands/pip/operations.rs index 3e254efe4..39734fd40 100644 --- a/crates/uv/src/commands/pip/operations.rs +++ b/crates/uv/src/commands/pip/operations.rs @@ -1,6 +1,6 @@ //! Common operations shared across the `pip` API and subcommands. -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use itertools::Itertools; use owo_colors::OwoColorize; use std::collections::{BTreeMap, BTreeSet, HashSet}; @@ -45,7 +45,7 @@ use uv_warnings::warn_user; use crate::commands::pip::loggers::{DefaultInstallLogger, InstallLogger, ResolveLogger}; use crate::commands::reporters::{InstallReporter, PrepareReporter, ResolverReporter}; -use crate::commands::{compile_bytecode, ChangeEventKind, DryRunEvent}; +use crate::commands::{ChangeEventKind, DryRunEvent, compile_bytecode}; use crate::printer::Printer; /// Consolidate the requirements for an installation. @@ -561,6 +561,7 @@ pub(crate) async fn install( } /// Display a message about the interpreter that was selected for the operation. +#[allow(clippy::result_large_err)] pub(crate) fn report_interpreter( python: &PythonInstallation, dimmed: bool, @@ -618,6 +619,7 @@ pub(crate) fn report_interpreter( } /// Display a message about the target environment for the operation. +#[allow(clippy::result_large_err)] pub(crate) fn report_target_environment( env: &PythonEnvironment, cache: &Cache, @@ -660,6 +662,7 @@ pub(crate) fn report_target_environment( } /// Report on the results of a dry-run installation. +#[allow(clippy::result_large_err)] fn report_dry_run( dry_run: DryRun, resolution: &Resolution, @@ -793,6 +796,7 @@ fn report_dry_run( } /// Report any diagnostics on resolved distributions. +#[allow(clippy::result_large_err)] pub(crate) fn diagnose_resolution( diagnostics: &[ResolutionDiagnostic], printer: Printer, @@ -810,6 +814,7 @@ pub(crate) fn diagnose_resolution( } /// Report any diagnostics on installed distributions in the Python environment. +#[allow(clippy::result_large_err)] pub(crate) fn diagnose_environment( resolution: &Resolution, venv: &PythonEnvironment, diff --git a/crates/uv/src/commands/pip/show.rs b/crates/uv/src/commands/pip/show.rs index b54dceac0..a77c29cd5 100644 --- a/crates/uv/src/commands/pip/show.rs +++ b/crates/uv/src/commands/pip/show.rs @@ -14,8 +14,8 @@ use uv_installer::SitePackages; use uv_normalize::PackageName; use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest}; -use crate::commands::pip::operations::report_target_environment; use crate::commands::ExitStatus; +use crate::commands::pip::operations::report_target_environment; use crate::printer::Printer; /// Show information about one or more installed packages. diff --git a/crates/uv/src/commands/pip/sync.rs b/crates/uv/src/commands/pip/sync.rs index 2b8d0babd..7831eee04 100644 --- a/crates/uv/src/commands/pip/sync.rs +++ b/crates/uv/src/commands/pip/sync.rs @@ -38,7 +38,7 @@ use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger}; use crate::commands::pip::operations::Modifications; use crate::commands::pip::operations::{report_interpreter, report_target_environment}; use crate::commands::pip::{operations, resolution_markers, resolution_tags}; -use crate::commands::{diagnostics, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/pip/tree.rs b/crates/uv/src/commands/pip/tree.rs index 70e39db7e..05290ffd0 100644 --- a/crates/uv/src/commands/pip/tree.rs +++ b/crates/uv/src/commands/pip/tree.rs @@ -4,9 +4,9 @@ use std::fmt::Write; use anyhow::Result; use futures::StreamExt; use owo_colors::OwoColorize; +use petgraph::Direction; use petgraph::graph::{EdgeIndex, NodeIndex}; use petgraph::prelude::EdgeRef; -use petgraph::Direction; use rustc_hash::{FxHashMap, FxHashSet}; use tokio::sync::Semaphore; @@ -23,10 +23,10 @@ use uv_pypi_types::{ResolutionMetadata, ResolverMarkerEnvironment, VerbatimParse use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest}; use uv_resolver::{ExcludeNewer, PrereleaseMode, RequiresPython}; +use crate::commands::ExitStatus; use crate::commands::pip::latest::LatestClient; use crate::commands::pip::operations::report_target_environment; use crate::commands::reporters::LatestVersionReporter; -use crate::commands::ExitStatus; use crate::printer::Printer; use crate::settings::NetworkSettings; @@ -119,7 +119,7 @@ pub(crate) async fn pip_tree( // Fetch the latest version for each package. let mut fetches = futures::stream::iter(&packages) - .map(|(name, ..)| async { + .map(async |(name, ..)| { let Some(filename) = client .find_latest(name, None, &download_concurrency) .await? diff --git a/crates/uv/src/commands/pip/uninstall.rs b/crates/uv/src/commands/pip/uninstall.rs index d5de7b459..787ba5aae 100644 --- a/crates/uv/src/commands/pip/uninstall.rs +++ b/crates/uv/src/commands/pip/uninstall.rs @@ -19,7 +19,7 @@ use uv_python::{Prefix, PythonEnvironment, Target}; use uv_requirements::{RequirementsSource, RequirementsSpecification}; use crate::commands::pip::operations::report_target_environment; -use crate::commands::{elapsed, ExitStatus}; +use crate::commands::{ExitStatus, elapsed}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 30c17e682..aaaeb8f3c 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -1,12 +1,12 @@ -use std::collections::hash_map::Entry; use std::collections::BTreeMap; +use std::collections::hash_map::Entry; use std::fmt::Write; use std::io; use std::path::Path; use std::str::FromStr; use std::sync::Arc; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use itertools::Itertools; use owo_colors::OwoColorize; use rustc_hash::{FxBuildHasher, FxHashMap}; @@ -23,13 +23,13 @@ use uv_configuration::{ use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; use uv_distribution_types::{ - redact_credentials, Index, IndexName, IndexUrls, NameRequirementSpecification, Requirement, - RequirementSource, UnresolvedRequirement, VersionId, + Index, IndexName, IndexUrls, NameRequirementSpecification, Requirement, RequirementSource, + UnresolvedRequirement, VersionId, redact_credentials, }; use uv_fs::Simplified; use uv_git::GIT_STORE; use uv_git_types::GitReference; -use uv_normalize::{DefaultExtras, PackageName, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, DefaultExtras, PackageName}; use uv_pep508::{ExtraName, MarkerTree, UnnamedRequirement, VersionOrUrl}; use uv_pypi_types::{ParsedUrl, VerbatimParsedUrl}; use uv_python::{Interpreter, PythonDownloads, PythonEnvironment, PythonPreference, PythonRequest}; @@ -51,11 +51,11 @@ use crate::commands::project::install_target::InstallTarget; use crate::commands::project::lock::LockMode; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - default_dependency_groups, init_script_python_requirement, PlatformState, ProjectEnvironment, - ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, + PlatformState, ProjectEnvironment, ProjectError, ProjectInterpreter, ScriptInterpreter, + UniversalState, default_dependency_groups, init_script_python_requirement, }; use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; -use crate::commands::{diagnostics, project, ExitStatus, ScriptPath}; +use crate::commands::{ExitStatus, ScriptPath, diagnostics, project}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings}; diff --git a/crates/uv/src/commands/project/environment.rs b/crates/uv/src/commands/project/environment.rs index 73325ce85..5d35f3bf8 100644 --- a/crates/uv/src/commands/project/environment.rs +++ b/crates/uv/src/commands/project/environment.rs @@ -9,7 +9,7 @@ use uv_python::{Interpreter, PythonEnvironment}; use crate::commands::pip::loggers::{InstallLogger, ResolveLogger}; use crate::commands::pip::operations::Modifications; use crate::commands::project::{ - resolve_environment, sync_environment, EnvironmentSpecification, PlatformState, ProjectError, + EnvironmentSpecification, PlatformState, ProjectError, resolve_environment, sync_environment, }; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings}; diff --git a/crates/uv/src/commands/project/export.rs b/crates/uv/src/commands/project/export.rs index 9eb55fd31..e33de8231 100644 --- a/crates/uv/src/commands/project/export.rs +++ b/crates/uv/src/commands/project/export.rs @@ -2,7 +2,7 @@ use std::env; use std::ffi::OsStr; use std::path::{Path, PathBuf}; -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; use itertools::Itertools; use owo_colors::OwoColorize; @@ -24,10 +24,10 @@ use crate::commands::project::install_target::InstallTarget; use crate::commands::project::lock::{LockMode, LockOperation}; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - default_dependency_groups, detect_conflicts, ProjectError, ProjectInterpreter, - ScriptInterpreter, UniversalState, + ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, default_dependency_groups, + detect_conflicts, }; -use crate::commands::{diagnostics, ExitStatus, OutputWriter}; +use crate::commands::{ExitStatus, OutputWriter, diagnostics}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverSettings}; diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 89f43723a..91e2fdc0c 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; use owo_colors::OwoColorize; use std::fmt::Write; use std::path::{Path, PathBuf}; @@ -12,7 +12,7 @@ use uv_client::BaseClientBuilder; use uv_configuration::{ PreviewMode, ProjectBuildBackend, VersionControlError, VersionControlSystem, }; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; use uv_git::GIT; use uv_pep440::Version; use uv_pep508::PackageName; @@ -28,9 +28,9 @@ use uv_warnings::warn_user_once; use uv_workspace::pyproject_mut::{DependencyTarget, PyProjectTomlMut}; use uv_workspace::{DiscoveryOptions, MemberDiscovery, Workspace, WorkspaceCache, WorkspaceError}; +use crate::commands::ExitStatus; use crate::commands::project::{find_requires_python, init_script_python_requirement}; use crate::commands::reporters::PythonDownloadReporter; -use crate::commands::ExitStatus; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/project/install_target.rs b/crates/uv/src/commands/project/install_target.rs index d6091c77c..d225114c9 100644 --- a/crates/uv/src/commands/project/install_target.rs +++ b/crates/uv/src/commands/project/install_target.rs @@ -11,8 +11,8 @@ use uv_normalize::PackageName; use uv_pypi_types::{DependencyGroupSpecifier, LenientRequirement, VerbatimParsedUrl}; use uv_resolver::{Installable, Lock, Package}; use uv_scripts::Pep723Script; -use uv_workspace::pyproject::{Source, Sources, ToolUvSources}; use uv_workspace::Workspace; +use uv_workspace::pyproject::{Source, Sources, ToolUvSources}; use crate::commands::project::ProjectError; diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index c99fc427a..93b51a60a 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -25,8 +25,8 @@ use uv_normalize::{GroupName, PackageName}; use uv_pep440::Version; use uv_pypi_types::{Conflicts, SupportedEnvironments}; use uv_python::{Interpreter, PythonDownloads, PythonEnvironment, PythonPreference, PythonRequest}; -use uv_requirements::upgrade::{read_lock_requirements, LockedRequirements}; use uv_requirements::ExtrasResolver; +use uv_requirements::upgrade::{LockedRequirements, read_lock_requirements}; use uv_resolver::{ FlatIndex, InMemoryIndex, Lock, Options, OptionsBuilder, PythonRequirement, RequiresPython, ResolverEnvironment, ResolverManifest, SatisfiesResult, UniversalMarker, @@ -40,16 +40,17 @@ use uv_workspace::{DiscoveryOptions, Workspace, WorkspaceCache, WorkspaceMember} use crate::commands::pip::loggers::{DefaultResolveLogger, ResolveLogger, SummaryResolveLogger}; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - init_script_python_requirement, ProjectError, ProjectInterpreter, ScriptInterpreter, - UniversalState, + ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, + init_script_python_requirement, }; use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; -use crate::commands::{diagnostics, pip, ExitStatus, ScriptPath}; +use crate::commands::{ExitStatus, ScriptPath, diagnostics, pip}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverSettings}; /// The result of running a lock operation. #[derive(Debug, Clone)] +#[allow(clippy::large_enum_variant)] pub(crate) enum LockResult { /// The lock was unchanged. Unchanged(Lock), diff --git a/crates/uv/src/commands/project/lock_target.rs b/crates/uv/src/commands/project/lock_target.rs index 593d7f9f8..cb45aa8ec 100644 --- a/crates/uv/src/commands/project/lock_target.rs +++ b/crates/uv/src/commands/project/lock_target.rs @@ -14,7 +14,7 @@ use uv_scripts::Pep723Script; use uv_workspace::dependency_groups::DependencyGroupError; use uv_workspace::{Workspace, WorkspaceMember}; -use crate::commands::project::{find_requires_python, ProjectError}; +use crate::commands::project::{ProjectError, find_requires_python}; /// A target that can be resolved into a lockfile. #[derive(Debug, Copy, Clone)] diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index f13fad4a9..9adeb7216 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -20,10 +20,10 @@ use uv_distribution::{DistributionDatabase, LoweredRequirement}; use uv_distribution_types::{ Index, Requirement, Resolution, UnresolvedRequirement, UnresolvedRequirementSpecification, }; -use uv_fs::{LockedFile, Simplified, CWD}; +use uv_fs::{CWD, LockedFile, Simplified}; use uv_git::ResolvedRepositoryReference; use uv_installer::{SatisfiesResult, SitePackages}; -use uv_normalize::{DefaultGroups, ExtraName, GroupName, PackageName, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, DefaultGroups, ExtraName, GroupName, PackageName}; use uv_pep440::{Version, VersionSpecifiers}; use uv_pep508::MarkerTreeContents; use uv_pypi_types::{ConflictPackage, ConflictSet, Conflicts}; @@ -32,7 +32,7 @@ use uv_python::{ PythonInstallation, PythonPreference, PythonRequest, PythonVariant, PythonVersionFile, VersionFileDiscoveryOptions, VersionRequest, }; -use uv_requirements::upgrade::{read_lock_requirements, LockedRequirements}; +use uv_requirements::upgrade::{LockedRequirements, read_lock_requirements}; use uv_requirements::{NamedRequirementsResolver, RequirementsSpecification}; use uv_resolver::{ FlatIndex, Lock, OptionsBuilder, Preference, PythonRequirement, RequiresPython, diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index 0537db16a..336641fce 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -13,7 +13,7 @@ use uv_configuration::{ PreviewMode, }; use uv_fs::Simplified; -use uv_normalize::{DefaultExtras, DEV_DEPENDENCIES}; +use uv_normalize::{DEV_DEPENDENCIES, DefaultExtras}; use uv_pep508::PackageName; use uv_python::{PythonDownloads, PythonPreference, PythonRequest}; use uv_scripts::{Pep723ItemRef, Pep723Metadata, Pep723Script}; @@ -30,10 +30,10 @@ use crate::commands::project::install_target::InstallTarget; use crate::commands::project::lock::LockMode; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - default_dependency_groups, ProjectEnvironment, ProjectError, ProjectInterpreter, - ScriptInterpreter, UniversalState, + ProjectEnvironment, ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, + default_dependency_groups, }; -use crate::commands::{diagnostics, project, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics, project}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings}; diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index a247fdfb3..038891779 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -5,7 +5,7 @@ use std::fmt::Write; use std::io::Read; use std::path::{Path, PathBuf}; -use anyhow::{anyhow, bail, Context}; +use anyhow::{Context, anyhow, bail}; use futures::StreamExt; use itertools::Itertools; use owo_colors::OwoColorize; @@ -48,14 +48,14 @@ use crate::commands::project::install_target::InstallTarget; use crate::commands::project::lock::LockMode; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ + EnvironmentSpecification, PreferenceSource, ProjectEnvironment, ProjectError, + ScriptEnvironment, ScriptInterpreter, UniversalState, WorkspacePython, default_dependency_groups, script_specification, update_environment, - validate_project_requires_python, EnvironmentSpecification, PreferenceSource, - ProjectEnvironment, ProjectError, ScriptEnvironment, ScriptInterpreter, UniversalState, - WorkspacePython, + validate_project_requires_python, }; use crate::commands::reporters::PythonDownloadReporter; use crate::commands::run::run_to_completion; -use crate::commands::{diagnostics, project, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics, project}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings}; @@ -570,7 +570,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl } } - let interpreter = if let Some(project) = project { + if let Some(project) = project { if let Some(project_name) = project.project_name() { debug!( "Discovered project `{project_name}` at: {}", @@ -876,9 +876,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl } else { interpreter } - }; - - interpreter + } }; debug!( diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 64cb69bcd..8e78836b4 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -39,10 +39,10 @@ use crate::commands::project::install_target::InstallTarget; use crate::commands::project::lock::{LockMode, LockOperation, LockResult}; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - default_dependency_groups, detect_conflicts, script_specification, update_environment, PlatformState, ProjectEnvironment, ProjectError, ScriptEnvironment, UniversalState, + default_dependency_groups, detect_conflicts, script_specification, update_environment, }; -use crate::commands::{diagnostics, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics}; use crate::printer::Printer; use crate::settings::{InstallerSettingsRef, NetworkSettings, ResolverInstallerSettings}; @@ -470,6 +470,7 @@ pub(crate) async fn sync( /// The outcome of a `lock` operation within a `sync` operation. #[derive(Debug)] +#[allow(clippy::large_enum_variant)] enum Outcome { /// The `lock` operation was successful. Success(Lock), diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index 97b4563fb..6bf57d1a7 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -23,10 +23,10 @@ use crate::commands::pip::resolution_markers; use crate::commands::project::lock::{LockMode, LockOperation}; use crate::commands::project::lock_target::LockTarget; use crate::commands::project::{ - default_dependency_groups, ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, + ProjectError, ProjectInterpreter, ScriptInterpreter, UniversalState, default_dependency_groups, }; use crate::commands::reporters::LatestVersionReporter; -use crate::commands::{diagnostics, ExitStatus}; +use crate::commands::{ExitStatus, diagnostics}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverSettings}; @@ -233,7 +233,7 @@ pub(crate) async fn tree( // Fetch the latest version for each package. let download_concurrency = &download_concurrency; let mut fetches = futures::stream::iter(packages) - .map(|(package, index)| async move { + .map(async |(package, index)| { // This probably already doesn't work for `--find-links`? let Some(filename) = client .find_latest(package.name(), Some(&index), download_concurrency) diff --git a/crates/uv/src/commands/publish.rs b/crates/uv/src/commands/publish.rs index 9190e1a90..98d7a0699 100644 --- a/crates/uv/src/commands/publish.rs +++ b/crates/uv/src/commands/publish.rs @@ -3,7 +3,7 @@ use std::iter; use std::sync::Arc; use std::time::Duration; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use console::Term; use owo_colors::OwoColorize; use tokio::sync::Semaphore; @@ -15,12 +15,12 @@ use uv_client::{AuthIntegration, BaseClient, BaseClientBuilder, RegistryClientBu use uv_configuration::{KeyringProviderType, TrustedPublishing}; use uv_distribution_types::{Index, IndexCapabilities, IndexLocations, IndexUrl}; use uv_publish::{ - check_trusted_publishing, files_for_publishing, upload, CheckUrlClient, TrustedPublishResult, + CheckUrlClient, TrustedPublishResult, check_trusted_publishing, files_for_publishing, upload, }; use uv_warnings::warn_user_once; use crate::commands::reporters::PublishReporter; -use crate::commands::{human_readable_bytes, ExitStatus}; +use crate::commands::{ExitStatus, human_readable_bytes}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/python/dir.rs b/crates/uv/src/commands/python/dir.rs index 27f469d9a..3c3f71172 100644 --- a/crates/uv/src/commands/python/dir.rs +++ b/crates/uv/src/commands/python/dir.rs @@ -3,7 +3,7 @@ use anyhow::Context; use owo_colors::OwoColorize; use uv_fs::Simplified; -use uv_python::managed::{python_executable_dir, ManagedPythonInstallations}; +use uv_python::managed::{ManagedPythonInstallations, python_executable_dir}; /// Show the Python installation directory. pub(crate) fn dir(bin: bool) -> anyhow::Result<()> { diff --git a/crates/uv/src/commands/python/find.rs b/crates/uv/src/commands/python/find.rs index 67590b9df..63e25fed1 100644 --- a/crates/uv/src/commands/python/find.rs +++ b/crates/uv/src/commands/python/find.rs @@ -13,8 +13,8 @@ use uv_warnings::{warn_user, warn_user_once}; use uv_workspace::{DiscoveryOptions, VirtualProject, WorkspaceCache, WorkspaceError}; use crate::commands::{ - project::{validate_project_requires_python, ScriptInterpreter, WorkspacePython}, ExitStatus, + project::{ScriptInterpreter, WorkspacePython, validate_project_requires_python}, }; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index 7f913bcb9..7e190d31d 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -4,8 +4,8 @@ use std::io::ErrorKind; use std::path::{Path, PathBuf}; use anyhow::{Error, Result}; -use futures::stream::FuturesUnordered; use futures::StreamExt; +use futures::stream::FuturesUnordered; use itertools::{Either, Itertools}; use owo_colors::OwoColorize; use rustc_hash::{FxHashMap, FxHashSet}; @@ -15,7 +15,7 @@ use uv_configuration::PreviewMode; use uv_fs::Simplified; use uv_python::downloads::{self, DownloadResult, ManagedPythonDownload, PythonDownloadRequest}; use uv_python::managed::{ - python_executable_dir, ManagedPythonInstallation, ManagedPythonInstallations, + ManagedPythonInstallation, ManagedPythonInstallations, python_executable_dir, }; use uv_python::platform::{Arch, Libc}; use uv_python::{ @@ -28,7 +28,7 @@ use uv_warnings::warn_user; use crate::commands::python::{ChangeEvent, ChangeEventKind}; use crate::commands::reporters::PythonDownloadReporter; -use crate::commands::{elapsed, ExitStatus}; +use crate::commands::{ExitStatus, elapsed}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/python/list.rs b/crates/uv/src/commands/python/list.rs index 5236b768d..a7f43ccdc 100644 --- a/crates/uv/src/commands/python/list.rs +++ b/crates/uv/src/commands/python/list.rs @@ -12,8 +12,8 @@ use uv_cache::Cache; use uv_fs::Simplified; use uv_python::downloads::PythonDownloadRequest; use uv_python::{ - find_python_installations, DiscoveryError, EnvironmentPreference, PythonDownloads, - PythonInstallation, PythonNotFound, PythonPreference, PythonRequest, PythonSource, + DiscoveryError, EnvironmentPreference, PythonDownloads, PythonInstallation, PythonNotFound, + PythonPreference, PythonRequest, PythonSource, find_python_installations, }; use crate::commands::ExitStatus; diff --git a/crates/uv/src/commands/python/pin.rs b/crates/uv/src/commands/python/pin.rs index 48c15c1b5..40dbfa1d9 100644 --- a/crates/uv/src/commands/python/pin.rs +++ b/crates/uv/src/commands/python/pin.rs @@ -2,7 +2,7 @@ use std::fmt::Write; use std::path::Path; use std::str::FromStr; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use owo_colors::OwoColorize; use tracing::debug; @@ -10,13 +10,13 @@ use uv_cache::Cache; use uv_dirs::user_uv_config_dir; use uv_fs::Simplified; use uv_python::{ - EnvironmentPreference, PythonInstallation, PythonPreference, PythonRequest, PythonVersionFile, - VersionFileDiscoveryOptions, PYTHON_VERSION_FILENAME, + EnvironmentPreference, PYTHON_VERSION_FILENAME, PythonInstallation, PythonPreference, + PythonRequest, PythonVersionFile, VersionFileDiscoveryOptions, }; use uv_warnings::warn_user_once; use uv_workspace::{DiscoveryOptions, VirtualProject, WorkspaceCache}; -use crate::commands::{project::find_requires_python, ExitStatus}; +use crate::commands::{ExitStatus, project::find_requires_python}; use crate::printer::Printer; /// Pin to a specific Python version. diff --git a/crates/uv/src/commands/python/uninstall.rs b/crates/uv/src/commands/python/uninstall.rs index 389b60071..ac159344c 100644 --- a/crates/uv/src/commands/python/uninstall.rs +++ b/crates/uv/src/commands/python/uninstall.rs @@ -3,8 +3,8 @@ use std::fmt::Write; use std::path::PathBuf; use anyhow::Result; -use futures::stream::FuturesUnordered; use futures::StreamExt; +use futures::stream::FuturesUnordered; use itertools::Itertools; use owo_colors::OwoColorize; use rustc_hash::{FxHashMap, FxHashSet}; @@ -13,12 +13,12 @@ use tracing::{debug, warn}; use uv_configuration::PreviewMode; use uv_fs::Simplified; use uv_python::downloads::PythonDownloadRequest; -use uv_python::managed::{python_executable_dir, ManagedPythonInstallations}; +use uv_python::managed::{ManagedPythonInstallations, python_executable_dir}; use uv_python::{PythonInstallationKey, PythonRequest}; use crate::commands::python::install::format_executables; use crate::commands::python::{ChangeEvent, ChangeEventKind}; -use crate::commands::{elapsed, ExitStatus}; +use crate::commands::{ExitStatus, elapsed}; use crate::printer::Printer; /// Uninstall managed Python versions. diff --git a/crates/uv/src/commands/run.rs b/crates/uv/src/commands/run.rs index 49b4cb070..4d827d194 100644 --- a/crates/uv/src/commands/run.rs +++ b/crates/uv/src/commands/run.rs @@ -42,9 +42,9 @@ pub(crate) async fn run_to_completion(mut handle: Child) -> anyhow::Result anyhow::Result<()> { diff --git a/crates/uv/src/commands/tool/install.rs b/crates/uv/src/commands/tool/install.rs index 0e9bdc607..bf05142f9 100644 --- a/crates/uv/src/commands/tool/install.rs +++ b/crates/uv/src/commands/tool/install.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use std::fmt::Write; use std::str::FromStr; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use owo_colors::OwoColorize; use tracing::{debug, trace}; @@ -26,15 +26,15 @@ use uv_tool::InstalledTools; use uv_warnings::warn_user; use uv_workspace::WorkspaceCache; +use crate::commands::ExitStatus; use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger}; use crate::commands::pip::operations::{self, Modifications}; use crate::commands::project::{ - resolve_environment, resolve_names, sync_environment, update_environment, - EnvironmentSpecification, PlatformState, ProjectError, + EnvironmentSpecification, PlatformState, ProjectError, resolve_environment, resolve_names, + sync_environment, update_environment, }; use crate::commands::tool::common::{install_executables, refine_interpreter, remove_entrypoints}; use crate::commands::tool::{Target, ToolRequest}; -use crate::commands::ExitStatus; use crate::commands::{diagnostics, reporters::PythonDownloadReporter}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings, ResolverSettings}; diff --git a/crates/uv/src/commands/tool/run.rs b/crates/uv/src/commands/tool/run.rs index 6316156e9..42f9e99a5 100644 --- a/crates/uv/src/commands/tool/run.rs +++ b/crates/uv/src/commands/tool/run.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use anstream::eprint; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use console::Term; use itertools::Itertools; use owo_colors::OwoColorize; @@ -38,23 +38,23 @@ use uv_requirements::{RequirementsSource, RequirementsSpecification}; use uv_settings::{PythonInstallMirrors, ResolverInstallerOptions, ToolOptions}; use uv_shell::runnable::WindowsRunnable; use uv_static::EnvVars; -use uv_tool::{entrypoint_paths, InstalledTools}; +use uv_tool::{InstalledTools, entrypoint_paths}; use uv_warnings::warn_user; use uv_warnings::warn_user_once; use uv_workspace::WorkspaceCache; +use crate::commands::ExitStatus; use crate::commands::pip::loggers::{ DefaultInstallLogger, DefaultResolveLogger, SummaryInstallLogger, SummaryResolveLogger, }; use crate::commands::pip::operations; use crate::commands::project::{ - resolve_names, EnvironmentSpecification, PlatformState, ProjectError, + EnvironmentSpecification, PlatformState, ProjectError, resolve_names, }; use crate::commands::reporters::PythonDownloadReporter; use crate::commands::run::run_to_completion; use crate::commands::tool::common::{matching_packages, refine_interpreter}; use crate::commands::tool::{Target, ToolRequest}; -use crate::commands::ExitStatus; use crate::commands::{diagnostics, project::environment::CachedEnvironment}; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/tool/uninstall.rs b/crates/uv/src/commands/tool/uninstall.rs index 44c32891d..c1f8ea8d7 100644 --- a/crates/uv/src/commands/tool/uninstall.rs +++ b/crates/uv/src/commands/tool/uninstall.rs @@ -1,6 +1,6 @@ use std::fmt::Write; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use itertools::Itertools; use owo_colors::OwoColorize; use tracing::debug; diff --git a/crates/uv/src/commands/tool/upgrade.rs b/crates/uv/src/commands/tool/upgrade.rs index 05055533f..9f4d3bcab 100644 --- a/crates/uv/src/commands/tool/upgrade.rs +++ b/crates/uv/src/commands/tool/upgrade.rs @@ -25,11 +25,11 @@ use crate::commands::pip::loggers::{ }; use crate::commands::pip::operations::Modifications; use crate::commands::project::{ - resolve_environment, sync_environment, update_environment, EnvironmentUpdate, PlatformState, + EnvironmentUpdate, PlatformState, resolve_environment, sync_environment, update_environment, }; use crate::commands::reporters::PythonDownloadReporter; use crate::commands::tool::common::remove_entrypoints; -use crate::commands::{conjunction, tool::common::install_executables, ExitStatus}; +use crate::commands::{ExitStatus, conjunction, tool::common::install_executables}; use crate::printer::Printer; use crate::settings::{NetworkSettings, ResolverInstallerSettings}; diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index c28d16507..c0cf03921 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -26,16 +26,16 @@ use uv_python::{ }; use uv_resolver::{ExcludeNewer, FlatIndex}; use uv_settings::PythonInstallMirrors; -use uv_shell::{shlex_posix, shlex_windows, Shell}; +use uv_shell::{Shell, shlex_posix, shlex_windows}; use uv_types::{AnyErrorBuild, BuildContext, BuildIsolation, BuildStack, HashStrategy}; use uv_warnings::warn_user; use uv_workspace::{DiscoveryOptions, VirtualProject, WorkspaceCache, WorkspaceError}; -use crate::commands::pip::loggers::{DefaultInstallLogger, InstallLogger}; -use crate::commands::pip::operations::{report_interpreter, Changelog}; -use crate::commands::project::{validate_project_requires_python, WorkspacePython}; -use crate::commands::reporters::PythonDownloadReporter; use crate::commands::ExitStatus; +use crate::commands::pip::loggers::{DefaultInstallLogger, InstallLogger}; +use crate::commands::pip::operations::{Changelog, report_interpreter}; +use crate::commands::project::{WorkspacePython, validate_project_requires_python}; +use crate::commands::reporters::PythonDownloadReporter; use crate::printer::Printer; use crate::settings::NetworkSettings; diff --git a/crates/uv/src/commands/version.rs b/crates/uv/src/commands/version.rs index 608e3be3a..bbc4027cc 100644 --- a/crates/uv/src/commands/version.rs +++ b/crates/uv/src/commands/version.rs @@ -2,7 +2,7 @@ use std::fmt::Write; use std::str::FromStr; use std::{cmp::Ordering, path::Path}; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use owo_colors::OwoColorize; use uv_cli::version::VersionInfo; @@ -12,8 +12,8 @@ use uv_pep440::Version; use uv_warnings::warn_user; use uv_workspace::pyproject_mut::Error; use uv_workspace::{ - pyproject_mut::{DependencyTarget, PyProjectTomlMut}, DiscoveryOptions, ProjectWorkspace, WorkspaceCache, + pyproject_mut::{DependencyTarget, PyProjectTomlMut}, }; use crate::{commands::ExitStatus, printer::Printer}; diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 2e8f5f19d..05174a947 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -11,7 +11,7 @@ use std::str::FromStr; use std::sync::atomic::Ordering; use anstream::eprintln; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use clap::error::{ContextKind, ContextValue}; use clap::{CommandFactory, Parser}; use futures::FutureExt; @@ -25,12 +25,12 @@ use uv_cache_info::Timestamp; #[cfg(feature = "self-update")] use uv_cli::SelfUpdateArgs; use uv_cli::{ - compat::CompatArgs, BuildBackendCommand, CacheCommand, CacheNamespace, Cli, Commands, - PipCommand, PipNamespace, ProjectCommand, PythonCommand, PythonNamespace, SelfCommand, - SelfNamespace, ToolCommand, ToolNamespace, TopLevelArgs, VersionArgs, + BuildBackendCommand, CacheCommand, CacheNamespace, Cli, Commands, PipCommand, PipNamespace, + ProjectCommand, PythonCommand, PythonNamespace, SelfCommand, SelfNamespace, ToolCommand, + ToolNamespace, TopLevelArgs, VersionArgs, compat::CompatArgs, }; use uv_configuration::min_stack_size; -use uv_fs::{Simplified, CWD}; +use uv_fs::{CWD, Simplified}; #[cfg(feature = "self-update")] use uv_pep440::release_specifiers_to_ranges; use uv_pep508::VersionOrUrl; @@ -423,7 +423,7 @@ async fn run(mut cli: Cli) -> Result { // Configure the cache. let cache = Cache::from_settings(cache_settings.no_cache, cache_settings.cache_dir)?; - let result = match *cli.command { + match *cli.command { Commands::Help(args) => commands::help( args.command.unwrap_or_default().as_slice(), printer, @@ -1609,8 +1609,7 @@ async fn run(mut cli: Cli) -> Result { }) .await .expect("tokio threadpool exited unexpectedly"), - }; - result + } } /// Run a [`ProjectCommand`]. diff --git a/crates/uv/src/logging.rs b/crates/uv/src/logging.rs index 49abd8864..98dad22c3 100644 --- a/crates/uv/src/logging.rs +++ b/crates/uv/src/logging.rs @@ -7,7 +7,7 @@ use owo_colors::OwoColorize; use tracing::{Event, Subscriber}; #[cfg(feature = "tracing-durations-export")] use tracing_durations_export::{ - plot::PlotConfig, DurationsLayer, DurationsLayerBuilder, DurationsLayerDropGuard, + DurationsLayer, DurationsLayerBuilder, DurationsLayerDropGuard, plot::PlotConfig, }; use tracing_subscriber::filter::Directive; use tracing_subscriber::fmt::format::Writer; @@ -16,8 +16,8 @@ use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::{EnvFilter, Layer, Registry}; -use tracing_tree::time::Uptime; use tracing_tree::HierarchicalLayer; +use tracing_tree::time::Uptime; use uv_cli::ColorChoice; use uv_static::EnvVars; diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 3ef289dee..f11ca7834 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -8,11 +8,6 @@ use url::Url; use uv_cache::{CacheArgs, Refresh}; use uv_cli::comma::CommaSeparatedRequirements; -use uv_cli::{ - options::{flag, resolver_installer_options, resolver_options}, - AuthorFrom, BuildArgs, ExportArgs, PublishArgs, PythonDirArgs, ResolverInstallerArgs, - ToolUpgradeArgs, -}; use uv_cli::{ AddArgs, ColorChoice, ExternalCommand, GlobalArgs, InitArgs, ListFormat, LockArgs, Maybe, PipCheckArgs, PipCompileArgs, PipFreezeArgs, PipInstallArgs, PipListArgs, PipShowArgs, @@ -20,6 +15,11 @@ use uv_cli::{ PythonListFormat, PythonPinArgs, PythonUninstallArgs, RemoveArgs, RunArgs, SyncArgs, ToolDirArgs, ToolInstallArgs, ToolListArgs, ToolRunArgs, ToolUninstallArgs, TreeArgs, VenvArgs, }; +use uv_cli::{ + AuthorFrom, BuildArgs, ExportArgs, PublishArgs, PythonDirArgs, ResolverInstallerArgs, + ToolUpgradeArgs, + options::{flag, resolver_installer_options, resolver_options}, +}; use uv_client::Connectivity; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, DependencyGroups, DryRun, EditableMode, @@ -47,7 +47,7 @@ use uv_warnings::warn_user_once; use uv_workspace::pyproject::DependencyType; use crate::commands::ToolRunCommand; -use crate::commands::{pip::operations::Modifications, InitKind, InitProjectKind}; +use crate::commands::{InitKind, InitProjectKind, pip::operations::Modifications}; /// The default publish URL. const PYPI_PUBLISH_URL: &str = "https://upload.pypi.org/legacy/"; diff --git a/crates/uv/tests/it/branching_urls.rs b/crates/uv/tests/it/branching_urls.rs index a246c55f9..09c77ef59 100644 --- a/crates/uv/tests/it/branching_urls.rs +++ b/crates/uv/tests/it/branching_urls.rs @@ -4,7 +4,7 @@ use anyhow::Result; use indoc::indoc; use insta::assert_snapshot; -use crate::common::{make_project, uv_snapshot, TestContext}; +use crate::common::{TestContext, make_project, uv_snapshot}; /// The root package has diverging URLs for disjoint markers: /// ```toml diff --git a/crates/uv/tests/it/build.rs b/crates/uv/tests/it/build.rs index 607920686..dc74d263f 100644 --- a/crates/uv/tests/it/build.rs +++ b/crates/uv/tests/it/build.rs @@ -1,4 +1,4 @@ -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; use anyhow::Result; use assert_cmd::assert::OutputAssertExt; use assert_fs::prelude::*; diff --git a/crates/uv/tests/it/build_backend.rs b/crates/uv/tests/it/build_backend.rs index 0e16083c4..ee4cde32b 100644 --- a/crates/uv/tests/it/build_backend.rs +++ b/crates/uv/tests/it/build_backend.rs @@ -1,4 +1,4 @@ -use crate::common::{uv_snapshot, venv_bin_path, TestContext}; +use crate::common::{TestContext, uv_snapshot, venv_bin_path}; use anyhow::Result; use assert_cmd::assert::OutputAssertExt; use assert_fs::fixture::{FileWriteStr, PathChild}; diff --git a/crates/uv/tests/it/cache_clean.rs b/crates/uv/tests/it/cache_clean.rs index 7a78346f8..857024947 100644 --- a/crates/uv/tests/it/cache_clean.rs +++ b/crates/uv/tests/it/cache_clean.rs @@ -2,7 +2,7 @@ use anyhow::Result; use assert_cmd::prelude::*; use assert_fs::prelude::*; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; /// `cache clean` should remove all packages. #[test] diff --git a/crates/uv/tests/it/cache_prune.rs b/crates/uv/tests/it/cache_prune.rs index 98d51836f..d760786d7 100644 --- a/crates/uv/tests/it/cache_prune.rs +++ b/crates/uv/tests/it/cache_prune.rs @@ -5,8 +5,8 @@ use indoc::indoc; use uv_static::EnvVars; -use crate::common::uv_snapshot; use crate::common::TestContext; +use crate::common::uv_snapshot; /// `cache prune` should be a no-op if there's nothing out-of-date in the cache. #[test] diff --git a/crates/uv/tests/it/common/mod.rs b/crates/uv/tests/it/common/mod.rs index 93fff441b..e21314456 100644 --- a/crates/uv/tests/it/common/mod.rs +++ b/crates/uv/tests/it/common/mod.rs @@ -12,7 +12,7 @@ use std::{env, io}; use assert_cmd::assert::{Assert, OutputAssertExt}; use assert_fs::assert::PathAssert; use assert_fs::fixture::{ChildPath, PathChild, PathCopy, PathCreateDir, SymlinkToFile}; -use base64::{prelude::BASE64_STANDARD as base64, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD as base64}; use etcetera::BaseStrategy; use futures::StreamExt; use indoc::formatdoc; @@ -1605,7 +1605,7 @@ pub const READ_ONLY_GITHUB_TOKEN_2: &[&str] = &[ /// Decode a split, base64 encoded authentication token. /// We split and encode the token to bypass revoke by GitHub's secret scanning pub fn decode_token(content: &[&str]) -> String { - let token = content + content .iter() .map(|part| base64.decode(part).unwrap()) .map(|decoded| { @@ -1614,8 +1614,7 @@ pub fn decode_token(content: &[&str]) -> String { .trim_end() .to_string() }) - .join("_"); - token + .join("_") } /// Simulates `reqwest::blocking::get` but returns bytes directly, and disables diff --git a/crates/uv/tests/it/ecosystem.rs b/crates/uv/tests/it/ecosystem.rs index 63eec84d9..e96dca62c 100644 --- a/crates/uv/tests/it/ecosystem.rs +++ b/crates/uv/tests/it/ecosystem.rs @@ -1,4 +1,4 @@ -use crate::common::{self, get_bin, TestContext}; +use crate::common::{self, TestContext, get_bin}; use anyhow::Result; use insta::assert_snapshot; use std::path::Path; diff --git a/crates/uv/tests/it/edit.rs b/crates/uv/tests/it/edit.rs index c1849f3f4..dda76b0b9 100644 --- a/crates/uv/tests/it/edit.rs +++ b/crates/uv/tests/it/edit.rs @@ -2,7 +2,7 @@ #[cfg(feature = "git")] mod conditional_imports { - pub(crate) use crate::common::{decode_token, READ_ONLY_GITHUB_TOKEN}; + pub(crate) use crate::common::{READ_ONLY_GITHUB_TOKEN, decode_token}; } #[cfg(feature = "git")] @@ -15,11 +15,11 @@ use indoc::{formatdoc, indoc}; use insta::assert_snapshot; use std::path::Path; use uv_fs::Simplified; -use wiremock::{matchers::method, Mock, MockServer, ResponseTemplate}; +use wiremock::{Mock, MockServer, ResponseTemplate, matchers::method}; use uv_static::EnvVars; -use crate::common::{packse_index_url, uv_snapshot, venv_bin_path, TestContext}; +use crate::common::{TestContext, packse_index_url, uv_snapshot, venv_bin_path}; /// Add a PyPI requirement. #[test] diff --git a/crates/uv/tests/it/export.rs b/crates/uv/tests/it/export.rs index 359fd5af7..019e6a831 100644 --- a/crates/uv/tests/it/export.rs +++ b/crates/uv/tests/it/export.rs @@ -1,6 +1,6 @@ #![allow(clippy::disallowed_types)] -use crate::common::{apply_filters, uv_snapshot, TestContext}; +use crate::common::{TestContext, apply_filters, uv_snapshot}; use anyhow::{Ok, Result}; use assert_cmd::assert::OutputAssertExt; use assert_fs::prelude::*; diff --git a/crates/uv/tests/it/help.rs b/crates/uv/tests/it/help.rs index 83837b313..bd9f87d72 100644 --- a/crates/uv/tests/it/help.rs +++ b/crates/uv/tests/it/help.rs @@ -1,6 +1,6 @@ use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn help() { diff --git a/crates/uv/tests/it/init.rs b/crates/uv/tests/it/init.rs index 9fff06a91..fe7489014 100644 --- a/crates/uv/tests/it/init.rs +++ b/crates/uv/tests/it/init.rs @@ -9,7 +9,7 @@ use predicates::prelude::predicate; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn init() { diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index c400aaa44..c181b26b7 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -7,8 +7,8 @@ use std::io::BufReader; use url::Url; use crate::common::{ - self, build_vendor_links_url, decode_token, download_to_disk, packse_index_url, uv_snapshot, - venv_bin_path, TestContext, + self, TestContext, build_vendor_links_url, decode_token, download_to_disk, packse_index_url, + uv_snapshot, venv_bin_path, }; use uv_fs::Simplified; use uv_static::EnvVars; diff --git a/crates/uv/tests/it/lock_conflict.rs b/crates/uv/tests/it/lock_conflict.rs index b011be440..3d596472e 100644 --- a/crates/uv/tests/it/lock_conflict.rs +++ b/crates/uv/tests/it/lock_conflict.rs @@ -2,7 +2,7 @@ use anyhow::Result; use assert_fs::prelude::*; use insta::assert_snapshot; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; // All of the tests in this file should use `tool.uv.conflicts` in some way. // diff --git a/crates/uv/tests/it/lock_scenarios.rs b/crates/uv/tests/it/lock_scenarios.rs index 4735c51b7..0b7af71a2 100644 --- a/crates/uv/tests/it/lock_scenarios.rs +++ b/crates/uv/tests/it/lock_scenarios.rs @@ -15,7 +15,7 @@ use insta::assert_snapshot; use uv_static::EnvVars; -use crate::common::{packse_index_url, uv_snapshot, TestContext}; +use crate::common::{TestContext, packse_index_url, uv_snapshot}; /// There are two packages, `a` and `b`. We select `a` with `a==2.0.0` first, and then `b`, but `a==2.0.0` conflicts with all new versions of `b`, so we backtrack through versions of `b`. /// diff --git a/crates/uv/tests/it/pip_check.rs b/crates/uv/tests/it/pip_check.rs index 7f4d9a459..891b1f050 100644 --- a/crates/uv/tests/it/pip_check.rs +++ b/crates/uv/tests/it/pip_check.rs @@ -2,8 +2,8 @@ use anyhow::Result; use assert_fs::fixture::FileWriteStr; use assert_fs::fixture::PathChild; -use crate::common::uv_snapshot; use crate::common::TestContext; +use crate::common::uv_snapshot; #[test] fn check_compatible_packages() -> Result<()> { diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index da7cfa6d2..a8c4d86bf 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -5,7 +5,7 @@ use std::fs; use std::io::Cursor; use std::path::PathBuf; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use assert_fs::prelude::*; use flate2::write::GzEncoder; use fs_err::File; @@ -17,7 +17,7 @@ use wiremock::{Mock, MockServer, ResponseTemplate}; use uv_fs::Simplified; use uv_static::EnvVars; -use crate::common::{download_to_disk, packse_index_url, uv_snapshot, TestContext}; +use crate::common::{TestContext, download_to_disk, packse_index_url, uv_snapshot}; #[test] fn compile_requirements_in() -> Result<()> { diff --git a/crates/uv/tests/it/pip_compile_scenarios.rs b/crates/uv/tests/it/pip_compile_scenarios.rs index ff0ff45ac..f7e583d92 100644 --- a/crates/uv/tests/it/pip_compile_scenarios.rs +++ b/crates/uv/tests/it/pip_compile_scenarios.rs @@ -16,8 +16,8 @@ use predicates::prelude::predicate; use uv_static::EnvVars; use crate::common::{ - build_vendor_links_url, get_bin, packse_index_url, python_path_with_versions, uv_snapshot, - TestContext, + TestContext, build_vendor_links_url, get_bin, packse_index_url, python_path_with_versions, + uv_snapshot, }; /// Provision python binaries and return a `pip compile` command with options shared across all scenarios. diff --git a/crates/uv/tests/it/pip_freeze.rs b/crates/uv/tests/it/pip_freeze.rs index 1502cf624..42c21bbe8 100644 --- a/crates/uv/tests/it/pip_freeze.rs +++ b/crates/uv/tests/it/pip_freeze.rs @@ -3,7 +3,7 @@ use assert_cmd::prelude::*; use assert_fs::fixture::ChildPath; use assert_fs::prelude::*; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn freeze_many() -> Result<()> { diff --git a/crates/uv/tests/it/pip_install.rs b/crates/uv/tests/it/pip_install.rs index 628da30ab..7a205f891 100644 --- a/crates/uv/tests/it/pip_install.rs +++ b/crates/uv/tests/it/pip_install.rs @@ -11,15 +11,15 @@ use indoc::indoc; use predicates::prelude::predicate; use url::Url; use wiremock::{ - matchers::{basic_auth, method, path}, Mock, MockServer, ResponseTemplate, + matchers::{basic_auth, method, path}, }; #[cfg(feature = "git")] use crate::common::{self, decode_token}; use crate::common::{ - build_vendor_links_url, download_to_disk, get_bin, uv_snapshot, venv_bin_path, - venv_to_interpreter, TestContext, + TestContext, build_vendor_links_url, download_to_disk, get_bin, uv_snapshot, venv_bin_path, + venv_to_interpreter, }; use uv_fs::Simplified; use uv_static::EnvVars; @@ -5228,8 +5228,8 @@ fn dry_run_install_already_installed() -> std::result::Result<(), Box std::result::Result<(), Box> { +fn dry_run_install_transitive_dependency_already_installed() +-> std::result::Result<(), Box> { let context = TestContext::new("3.12"); let requirements_txt = context.temp_dir.child("requirements.txt"); diff --git a/crates/uv/tests/it/pip_install_scenarios.rs b/crates/uv/tests/it/pip_install_scenarios.rs index 41008cdb4..c1c68b078 100644 --- a/crates/uv/tests/it/pip_install_scenarios.rs +++ b/crates/uv/tests/it/pip_install_scenarios.rs @@ -14,8 +14,8 @@ use assert_cmd::prelude::*; use uv_static::EnvVars; use crate::common::{ - build_vendor_links_url, get_bin, packse_index_url, uv_snapshot, venv_to_interpreter, - TestContext, + TestContext, build_vendor_links_url, get_bin, packse_index_url, uv_snapshot, + venv_to_interpreter, }; fn assert_command(venv: &Path, command: &str, temp_dir: &Path) -> Assert { diff --git a/crates/uv/tests/it/pip_list.rs b/crates/uv/tests/it/pip_list.rs index a47283daa..5c26c03aa 100644 --- a/crates/uv/tests/it/pip_list.rs +++ b/crates/uv/tests/it/pip_list.rs @@ -4,7 +4,7 @@ use assert_fs::fixture::FileWriteStr; use assert_fs::fixture::PathChild; use assert_fs::prelude::*; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn list_empty_columns() { diff --git a/crates/uv/tests/it/pip_show.rs b/crates/uv/tests/it/pip_show.rs index 31b4c02cb..4371b089e 100644 --- a/crates/uv/tests/it/pip_show.rs +++ b/crates/uv/tests/it/pip_show.rs @@ -8,7 +8,7 @@ use indoc::indoc; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn show_empty() { diff --git a/crates/uv/tests/it/pip_sync.rs b/crates/uv/tests/it/pip_sync.rs index 1b0566fc7..2c704c276 100644 --- a/crates/uv/tests/it/pip_sync.rs +++ b/crates/uv/tests/it/pip_sync.rs @@ -12,9 +12,9 @@ use predicates::Predicate; use url::Url; use crate::common::{ - download_to_disk, site_packages_path, uv_snapshot, venv_to_interpreter, TestContext, + TestContext, download_to_disk, site_packages_path, uv_snapshot, venv_to_interpreter, }; -use uv_fs::{copy_dir_all, Simplified}; +use uv_fs::{Simplified, copy_dir_all}; use uv_static::EnvVars; fn check_command(venv: &Path, command: &str, temp_dir: &Path) { @@ -129,12 +129,14 @@ fn install() -> Result<()> { ); // Counterpart for the `compile()` test. - assert!(!context - .site_packages() - .join("markupsafe") - .join("__pycache__") - .join("__init__.cpython-312.pyc") - .exists()); + assert!( + !context + .site_packages() + .join("markupsafe") + .join("__pycache__") + .join("__init__.cpython-312.pyc") + .exists() + ); context .assert_command("from markupsafe import Markup") @@ -3293,12 +3295,14 @@ fn compile() -> Result<()> { "### ); - assert!(context - .site_packages() - .join("markupsafe") - .join("__pycache__") - .join("__init__.cpython-312.pyc") - .exists()); + assert!( + context + .site_packages() + .join("markupsafe") + .join("__pycache__") + .join("__init__.cpython-312.pyc") + .exists() + ); context.assert_command("import markupsafe").success(); @@ -3342,12 +3346,14 @@ fn recompile() -> Result<()> { "### ); - assert!(context - .site_packages() - .join("markupsafe") - .join("__pycache__") - .join("__init__.cpython-312.pyc") - .exists()); + assert!( + context + .site_packages() + .join("markupsafe") + .join("__pycache__") + .join("__init__.cpython-312.pyc") + .exists() + ); context.assert_command("import markupsafe").success(); @@ -5267,12 +5273,14 @@ fn target_built_distribution() -> Result<()> { - iniconfig==1.1.1 "###); // Ensure that the binary is present in the target directory. - assert!(context - .temp_dir - .child("target") - .child("bin") - .child(format!("flask{EXE_SUFFIX}")) - .is_file()); + assert!( + context + .temp_dir + .child("target") + .child("bin") + .child(format!("flask{EXE_SUFFIX}")) + .is_file() + ); Ok(()) } diff --git a/crates/uv/tests/it/pip_tree.rs b/crates/uv/tests/it/pip_tree.rs index c4b997e7e..085d2e08d 100644 --- a/crates/uv/tests/it/pip_tree.rs +++ b/crates/uv/tests/it/pip_tree.rs @@ -8,7 +8,7 @@ use assert_fs::fixture::PathChild; use uv_static::EnvVars; use crate::common::get_bin; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn no_package() { diff --git a/crates/uv/tests/it/pip_uninstall.rs b/crates/uv/tests/it/pip_uninstall.rs index 8cf30d986..5c820673d 100644 --- a/crates/uv/tests/it/pip_uninstall.rs +++ b/crates/uv/tests/it/pip_uninstall.rs @@ -5,7 +5,7 @@ use assert_cmd::prelude::*; use assert_fs::fixture::ChildPath; use assert_fs::prelude::*; -use crate::common::{get_bin, uv_snapshot, venv_to_interpreter, TestContext}; +use crate::common::{TestContext, get_bin, uv_snapshot, venv_to_interpreter}; #[test] fn no_arguments() { @@ -547,9 +547,11 @@ fn dry_run_uninstall_egg_info() -> Result<()> { "###); // The `.egg-info` directory should still exist. - assert!(site_packages - .child("zstandard-0.22.0-py3.12.egg-info") - .exists()); + assert!( + site_packages + .child("zstandard-0.22.0-py3.12.egg-info") + .exists() + ); // The package directory should still exist. assert!(site_packages.child("zstd").child("__init__.py").exists()); diff --git a/crates/uv/tests/it/publish.rs b/crates/uv/tests/it/publish.rs index a45ccb801..0fdf435e8 100644 --- a/crates/uv/tests/it/publish.rs +++ b/crates/uv/tests/it/publish.rs @@ -1,4 +1,4 @@ -use crate::common::{uv_snapshot, venv_bin_path, TestContext}; +use crate::common::{TestContext, uv_snapshot, venv_bin_path}; use assert_cmd::assert::OutputAssertExt; use assert_fs::fixture::{FileTouch, FileWriteStr, PathChild}; use indoc::indoc; diff --git a/crates/uv/tests/it/python_dir.rs b/crates/uv/tests/it/python_dir.rs index 9ef536e67..9a49b4ea1 100644 --- a/crates/uv/tests/it/python_dir.rs +++ b/crates/uv/tests/it/python_dir.rs @@ -2,7 +2,7 @@ use assert_fs::fixture::PathChild; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn python_dir() { diff --git a/crates/uv/tests/it/python_find.rs b/crates/uv/tests/it/python_find.rs index 621385729..90615da2d 100644 --- a/crates/uv/tests/it/python_find.rs +++ b/crates/uv/tests/it/python_find.rs @@ -5,7 +5,7 @@ use indoc::indoc; use uv_python::platform::{Arch, Os}; use uv_static::EnvVars; -use crate::common::{uv_snapshot, venv_bin_path, TestContext}; +use crate::common::{TestContext, uv_snapshot, venv_bin_path}; #[test] fn python_find() { diff --git a/crates/uv/tests/it/python_install.rs b/crates/uv/tests/it/python_install.rs index 301e6f914..f18a9e94e 100644 --- a/crates/uv/tests/it/python_install.rs +++ b/crates/uv/tests/it/python_install.rs @@ -1,6 +1,6 @@ use std::{env, path::Path, process::Command}; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; use assert_fs::{ assert::PathAssert, prelude::{FileTouch, PathChild, PathCreateDir}, @@ -998,8 +998,8 @@ fn read_link_path(path: &Path) -> String { .ok() .unwrap_or_else(|| panic!("{} should be readable", path.display())) .unwrap_or_else(|| panic!("{} should be a valid launcher", path.display())); - let path = launcher.python_path.simplified_display().to_string(); - path + + launcher.python_path.simplified_display().to_string() } else { unreachable!() } diff --git a/crates/uv/tests/it/python_list.rs b/crates/uv/tests/it/python_list.rs index 1343016c4..7dfcf70dc 100644 --- a/crates/uv/tests/it/python_list.rs +++ b/crates/uv/tests/it/python_list.rs @@ -1,7 +1,7 @@ use uv_python::platform::{Arch, Os}; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn python_list() { diff --git a/crates/uv/tests/it/python_pin.rs b/crates/uv/tests/it/python_pin.rs index 8e34db193..d6c267c7a 100644 --- a/crates/uv/tests/it/python_pin.rs +++ b/crates/uv/tests/it/python_pin.rs @@ -1,12 +1,12 @@ use std::path::PathBuf; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; use anyhow::Result; use assert_fs::fixture::{FileWriteStr, PathChild, PathCreateDir}; use insta::assert_snapshot; use uv_python::{ + PYTHON_VERSION_FILENAME, PYTHON_VERSIONS_FILENAME, platform::{Arch, Os}, - PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME, }; #[test] diff --git a/crates/uv/tests/it/run.rs b/crates/uv/tests/it/run.rs index 6688db2b6..d778da8ba 100644 --- a/crates/uv/tests/it/run.rs +++ b/crates/uv/tests/it/run.rs @@ -11,7 +11,7 @@ use uv_fs::copy_dir_all; use uv_python::PYTHON_VERSION_FILENAME; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn run_with_python_version() -> Result<()> { diff --git a/crates/uv/tests/it/self_update.rs b/crates/uv/tests/it/self_update.rs index 82779c6d0..b8458929b 100644 --- a/crates/uv/tests/it/self_update.rs +++ b/crates/uv/tests/it/self_update.rs @@ -1,8 +1,8 @@ use std::process::Command; use axoupdater::{ - test::helpers::{perform_runtest, RuntestArgs}, ReleaseSourceType, + test::helpers::{RuntestArgs, perform_runtest}, }; use uv_static::EnvVars; diff --git a/crates/uv/tests/it/show_settings.rs b/crates/uv/tests/it/show_settings.rs index 786cd84dd..dd61389b5 100644 --- a/crates/uv/tests/it/show_settings.rs +++ b/crates/uv/tests/it/show_settings.rs @@ -4,7 +4,7 @@ use std::process::Command; use assert_fs::prelude::*; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; /// Add shared arguments to a command. /// diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 6ab00bfc6..5bfcf7617 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -4,7 +4,7 @@ use assert_fs::{fixture::ChildPath, prelude::*}; use indoc::{formatdoc, indoc}; use insta::assert_snapshot; -use crate::common::{download_to_disk, uv_snapshot, venv_bin_path, TestContext}; +use crate::common::{TestContext, download_to_disk, uv_snapshot, venv_bin_path}; use predicates::prelude::predicate; use tempfile::tempdir_in; use uv_fs::Simplified; diff --git a/crates/uv/tests/it/tool_dir.rs b/crates/uv/tests/it/tool_dir.rs index 662cbde38..fb04e6d92 100644 --- a/crates/uv/tests/it/tool_dir.rs +++ b/crates/uv/tests/it/tool_dir.rs @@ -2,7 +2,7 @@ use assert_fs::fixture::PathChild; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn tool_dir() { diff --git a/crates/uv/tests/it/tool_install.rs b/crates/uv/tests/it/tool_install.rs index 9b32bcc26..7720e982b 100644 --- a/crates/uv/tests/it/tool_install.rs +++ b/crates/uv/tests/it/tool_install.rs @@ -11,7 +11,7 @@ use predicates::prelude::predicate; use uv_fs::copy_dir_all; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn tool_install() { @@ -126,9 +126,11 @@ fn tool_install() { "###); tool_dir.child("flask").assert(predicate::path::is_dir()); - assert!(bin_dir - .child(format!("flask{}", std::env::consts::EXE_SUFFIX)) - .exists()); + assert!( + bin_dir + .child(format!("flask{}", std::env::consts::EXE_SUFFIX)) + .exists() + ); #[cfg(not(windows))] insta::with_settings!({ @@ -211,9 +213,11 @@ fn tool_install_with_global_python() -> Result<()> { "###); tool_dir.child("flask").assert(predicate::path::is_dir()); - assert!(bin_dir - .child(format!("flask{}", std::env::consts::EXE_SUFFIX)) - .exists()); + assert!( + bin_dir + .child(format!("flask{}", std::env::consts::EXE_SUFFIX)) + .exists() + ); uv_snapshot!(context.filters(), Command::new("flask").arg("--version").env(EnvVars::PATH, bin_dir.as_os_str()), @r###" success: true diff --git a/crates/uv/tests/it/tool_list.rs b/crates/uv/tests/it/tool_list.rs index 7bc00116d..d2c635534 100644 --- a/crates/uv/tests/it/tool_list.rs +++ b/crates/uv/tests/it/tool_list.rs @@ -1,4 +1,4 @@ -use crate::common::{self, uv_snapshot, TestContext}; +use crate::common::{self, TestContext, uv_snapshot}; use anyhow::Result; use assert_cmd::assert::OutputAssertExt; use assert_fs::fixture::PathChild; diff --git a/crates/uv/tests/it/tool_run.rs b/crates/uv/tests/it/tool_run.rs index bcf0a88cb..7cf772147 100644 --- a/crates/uv/tests/it/tool_run.rs +++ b/crates/uv/tests/it/tool_run.rs @@ -1,4 +1,4 @@ -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; use anyhow::Result; use assert_cmd::prelude::*; use assert_fs::prelude::*; diff --git a/crates/uv/tests/it/tool_uninstall.rs b/crates/uv/tests/it/tool_uninstall.rs index f51d56bf8..ae194217d 100644 --- a/crates/uv/tests/it/tool_uninstall.rs +++ b/crates/uv/tests/it/tool_uninstall.rs @@ -3,7 +3,7 @@ use assert_fs::fixture::PathChild; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn tool_uninstall() { diff --git a/crates/uv/tests/it/tool_upgrade.rs b/crates/uv/tests/it/tool_upgrade.rs index c3f05d2ec..a36db9b92 100644 --- a/crates/uv/tests/it/tool_upgrade.rs +++ b/crates/uv/tests/it/tool_upgrade.rs @@ -3,7 +3,7 @@ use insta::assert_snapshot; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn tool_upgrade_empty() { diff --git a/crates/uv/tests/it/tree.rs b/crates/uv/tests/it/tree.rs index 45a49080b..66d7cf2bc 100644 --- a/crates/uv/tests/it/tree.rs +++ b/crates/uv/tests/it/tree.rs @@ -5,7 +5,7 @@ use indoc::{formatdoc, indoc}; use insta::assert_snapshot; use url::Url; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn nested_dependencies() -> Result<()> { diff --git a/crates/uv/tests/it/venv.rs b/crates/uv/tests/it/venv.rs index 9518b2bf2..d601b2535 100644 --- a/crates/uv/tests/it/venv.rs +++ b/crates/uv/tests/it/venv.rs @@ -3,10 +3,10 @@ use assert_cmd::prelude::*; use assert_fs::prelude::*; use indoc::indoc; use predicates::prelude::*; -use uv_python::{PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME}; +use uv_python::{PYTHON_VERSION_FILENAME, PYTHON_VERSIONS_FILENAME}; use uv_static::EnvVars; -use crate::common::{uv_snapshot, TestContext}; +use crate::common::{TestContext, uv_snapshot}; #[test] fn create_venv() { diff --git a/crates/uv/tests/it/version.rs b/crates/uv/tests/it/version.rs index 50153fe73..51682a59b 100644 --- a/crates/uv/tests/it/version.rs +++ b/crates/uv/tests/it/version.rs @@ -3,8 +3,8 @@ use assert_cmd::assert::OutputAssertExt; use assert_fs::prelude::*; use insta::assert_snapshot; -use crate::common::uv_snapshot; use crate::common::TestContext; +use crate::common::uv_snapshot; // Print the version #[test] diff --git a/crates/uv/tests/it/workflow.rs b/crates/uv/tests/it/workflow.rs index 9888dc97a..e78d6e87b 100644 --- a/crates/uv/tests/it/workflow.rs +++ b/crates/uv/tests/it/workflow.rs @@ -1,4 +1,4 @@ -use crate::common::{diff_snapshot, uv_snapshot, TestContext}; +use crate::common::{TestContext, diff_snapshot, uv_snapshot}; use anyhow::Result; use assert_fs::fixture::{FileWriteStr, PathChild}; use insta::assert_snapshot; diff --git a/crates/uv/tests/it/workspace.rs b/crates/uv/tests/it/workspace.rs index d94961ef6..1b375597c 100644 --- a/crates/uv/tests/it/workspace.rs +++ b/crates/uv/tests/it/workspace.rs @@ -10,7 +10,7 @@ use indoc::indoc; use insta::{assert_json_snapshot, assert_snapshot}; use serde::{Deserialize, Serialize}; -use crate::common::{copy_dir_ignore, make_project, uv_snapshot, TestContext}; +use crate::common::{TestContext, copy_dir_ignore, make_project, uv_snapshot}; fn workspaces_dir() -> PathBuf { env::current_dir() diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e7f22fb8b..0837c1fca 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.86" +channel = "1.87"