Skip to content

Commit

Permalink
ensure PEP 691 json parsing also supports PEP 658 dist-info-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Sep 5, 2022
1 parent 266c5cd commit 8da1bdc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pip/_internal/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ def from_json(
if file_url is None:
return None

url = _ensure_quoted_url(urllib.parse.urljoin(page_url, file_url))
pyrequire = file_data.get("requires-python")
yanked_reason = file_data.get("yanked")
dist_info_metadata = file_data.get("dist-info-metadata")
hashes = file_data.get("hashes", {})

# The Link.yanked_reason expects an empty string instead of a boolean.
if yanked_reason and not isinstance(yanked_reason, str):
yanked_reason = ""
Expand All @@ -255,11 +260,12 @@ def from_json(
yanked_reason = None

return cls(
_ensure_quoted_url(urllib.parse.urljoin(page_url, file_url)),
url,
comes_from=page_url,
requires_python=file_data.get("requires-python"),
requires_python=pyrequire,
yanked_reason=yanked_reason,
hashes=file_data.get("hashes", {}),
hashes=hashes,
dist_info_metadata=dist_info_metadata,
)

@classmethod
Expand Down

0 comments on commit 8da1bdc

Please sign in to comment.