Skip to content

Commit

Permalink
Improve error message for cache info serialization (#8500)
Browse files Browse the repository at this point in the history
## Summary

We no longer need this struct; we bumped the cache bucket version
anyway, so the `Timestamp` variant is never encountered. This means we
get real Serde error messages.

Closes #8488.
  • Loading branch information
charliermarsh authored Oct 23, 2024
1 parent fa14ea4 commit 29193ac
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions crates/uv-cache-info/src/cache_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub enum CacheInfoError {
/// timestamps of relevant files, the current commit of a repository, etc.
#[derive(Default, Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(try_from = "CacheInfoWire")]
pub struct CacheInfo {
/// The timestamp of the most recent `ctime` of any relevant files, at the time of the build.
/// The timestamp will typically be the maximum of the `ctime` values of the `pyproject.toml`,
Expand Down Expand Up @@ -200,46 +199,6 @@ impl CacheInfo {
}
}

#[derive(Debug, serde::Deserialize)]
struct TimestampCommit {
#[serde(default)]
timestamp: Option<Timestamp>,
#[serde(default)]
commit: Option<Commit>,
#[serde(default)]
tags: Option<Tags>,
}

#[derive(Debug, serde::Deserialize)]
#[serde(untagged)]
enum CacheInfoWire {
/// For backwards-compatibility, enable deserializing [`CacheInfo`] structs that are solely
/// represented by a timestamp.
Timestamp(Timestamp),
/// A [`CacheInfo`] struct that includes both a timestamp and a commit.
TimestampCommit(TimestampCommit),
}

impl From<CacheInfoWire> for CacheInfo {
fn from(wire: CacheInfoWire) -> Self {
match wire {
CacheInfoWire::Timestamp(timestamp) => Self {
timestamp: Some(timestamp),
..Self::default()
},
CacheInfoWire::TimestampCommit(TimestampCommit {
timestamp,
commit,
tags,
}) => Self {
timestamp,
commit,
tags,
},
}
}
}

/// A `pyproject.toml` with an (optional) `[tool.uv]` section.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
Expand Down

0 comments on commit 29193ac

Please sign in to comment.