mirror of https://github.com/astral-sh/uv
Implement `CacheKey` for all `Pep508Url` variants (#14978)
Closes #14973
This commit is contained in:
parent
a76e538aa5
commit
c9d3d60a18
|
|
@ -5646,6 +5646,7 @@ dependencies = [
|
||||||
"toml_edit",
|
"toml_edit",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
|
"uv-cache-key",
|
||||||
"uv-distribution-filename",
|
"uv-distribution-filename",
|
||||||
"uv-git-types",
|
"uv-git-types",
|
||||||
"uv-normalize",
|
"uv-normalize",
|
||||||
|
|
|
||||||
|
|
@ -252,10 +252,7 @@ impl<T: Pep508Url> Serialize for Requirement<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Pep508Url> CacheKey for Requirement<T>
|
impl<T: Pep508Url> CacheKey for Requirement<T> {
|
||||||
where
|
|
||||||
T: Display,
|
|
||||||
{
|
|
||||||
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
||||||
self.name.as_str().cache_key(state);
|
self.name.as_str().cache_key(state);
|
||||||
|
|
||||||
|
|
@ -280,7 +277,7 @@ where
|
||||||
}
|
}
|
||||||
VersionOrUrl::Url(url) => {
|
VersionOrUrl::Url(url) => {
|
||||||
1u8.cache_key(state);
|
1u8.cache_key(state);
|
||||||
url.to_string().cache_key(state);
|
url.cache_key(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -330,7 +327,7 @@ impl<T: Pep508Url> Requirement<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type to parse URLs from `name @ <url>` into. Defaults to [`Url`].
|
/// Type to parse URLs from `name @ <url>` into. Defaults to [`Url`].
|
||||||
pub trait Pep508Url: Display + Debug + Sized {
|
pub trait Pep508Url: Display + Debug + Sized + CacheKey {
|
||||||
/// String to URL parsing error
|
/// String to URL parsing error
|
||||||
type Err: Error + Debug;
|
type Err: Error + Debug;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use arcstr::ArcStr;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use url::{ParseError, Url};
|
use url::{ParseError, Url};
|
||||||
|
use uv_cache_key::{CacheKey, CacheKeyHasher};
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "non-pep508-extensions"), allow(unused_imports))]
|
#[cfg_attr(not(feature = "non-pep508-extensions"), allow(unused_imports))]
|
||||||
use uv_fs::{normalize_absolute_path, normalize_url_path};
|
use uv_fs::{normalize_absolute_path, normalize_url_path};
|
||||||
|
|
@ -37,6 +38,12 @@ impl Hash for VerbatimUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CacheKey for VerbatimUrl {
|
||||||
|
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
||||||
|
self.url.as_str().cache_key(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for VerbatimUrl {
|
impl PartialEq for VerbatimUrl {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.url == other.url
|
self.url == other.url
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ doctest = false
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
uv-cache-key = { workspace = true }
|
||||||
uv-distribution-filename = { workspace = true }
|
uv-distribution-filename = { workspace = true }
|
||||||
uv-git-types = { workspace = true }
|
uv-git-types = { workspace = true }
|
||||||
uv-normalize = { workspace = true }
|
uv-normalize = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use url::{ParseError, Url};
|
use url::{ParseError, Url};
|
||||||
|
use uv_cache_key::{CacheKey, CacheKeyHasher};
|
||||||
|
|
||||||
use uv_distribution_filename::{DistExtension, ExtensionError};
|
use uv_distribution_filename::{DistExtension, ExtensionError};
|
||||||
use uv_git_types::{GitUrl, GitUrlParseError};
|
use uv_git_types::{GitUrl, GitUrlParseError};
|
||||||
|
|
@ -45,6 +46,12 @@ pub struct VerbatimParsedUrl {
|
||||||
pub verbatim: VerbatimUrl,
|
pub verbatim: VerbatimUrl,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CacheKey for VerbatimParsedUrl {
|
||||||
|
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
||||||
|
self.verbatim.cache_key(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl VerbatimParsedUrl {
|
impl VerbatimParsedUrl {
|
||||||
/// Returns `true` if the URL is editable.
|
/// Returns `true` if the URL is editable.
|
||||||
pub fn is_editable(&self) -> bool {
|
pub fn is_editable(&self) -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue