Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic and provides_extra to JSON schema #79

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

- :release:`5.1.0 <26th February 2024>`
- :bug:`78` Add ``dynamic`` and ``provides_extra`` to JSON schema

- :release:`5.0.2 <3rd February 2024>`
- :bug:`74` Remove none-check from publication_date

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "letsbuilda-pypi"
version = "5.0.2"
version = "5.1.0"
description = "A wrapper for PyPI's API and RSS feed"
authors = [
{ name = "Bradley Reynolds", email = "[email protected]" },
Expand Down
35 changes: 34 additions & 1 deletion src/letsbuilda/pypi/models/models_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass
from datetime import datetime
from typing import Self
from typing import Literal, Self


@dataclass(frozen=True)
Expand Down Expand Up @@ -114,10 +114,43 @@ class Info:
version: str
yanked: bool
yanked_reason: str | None
dynamic: (
list[
Literal[
"Platform",
"Supported-Platform",
"Summary",
"Description",
"Description-Content-Type",
"Keywords",
"Home-page",
"Download-URL",
"Author",
"Author-email",
"Maintainer",
"Maintainer-email",
"License",
"Classifier",
"Requires-Dist",
"Requires-Python",
"Requires-External",
"Project-URL",
"Provides-Extra",
"Provides-Dist",
"Obsoletes-Dist",
]
]
| None
)
provides_extra: list[str] | None

@classmethod
def from_dict(cls: type[Self], data: dict) -> Self: # type: ignore[type-arg]
"""Build an instance from a dictionary."""
if "dynamic" not in data:
data["dynamic"] = None
if "provides_extra" not in data:
data["provides_extra"] = None
shenanigansd marked this conversation as resolved.
Show resolved Hide resolved
return cls(**data)


Expand Down
Loading