Skip to content

Commit

Permalink
Add PEP 714 support for JSON API client
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed May 21, 2024
1 parent 76418f5 commit 12c6e79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/distribution-types/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl File {
pub fn try_from(file: pypi_types::File, base: &Url) -> Result<Self, FileConversionError> {
Ok(Self {
dist_info_metadata: file
.dist_info_metadata
.core_metadata
.as_ref()
.is_some_and(DistInfoMetadata::is_available),
filename: file.filename,
Expand Down
7 changes: 4 additions & 3 deletions crates/pypi-types/src/simple_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ fn sorted_simple_json_files<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<File>
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct File {
// Non-PEP 691-compliant alias used by PyPI.
#[serde(alias = "data-dist-info-metadata")]
pub dist_info_metadata: Option<DistInfoMetadata>,
// PEP 714-renamed field, followed by PEP 691-compliant field, followed by non-PEP 691-compliant
// alias used by PyPI.
#[serde(alias = "dist-info-metadata", alias = "data-dist-info-metadata")]
pub core_metadata: Option<DistInfoMetadata>,
pub filename: String,
pub hashes: Hashes,
/// There are a number of invalid specifiers on pypi, so we first try to parse it into a [`VersionSpecifiers`]
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl SimpleHtml {
};

Ok(File {
dist_info_metadata,
core_metadata: dist_info_metadata,
yanked,
requires_python,
hashes,
Expand Down

0 comments on commit 12c6e79

Please sign in to comment.