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

put pretty names in metadata #620

Merged
merged 2 commits into from
Aug 5, 2023
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
6 changes: 2 additions & 4 deletions src/poetry/core/masonry/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@


if TYPE_CHECKING:
from packaging.utils import NormalizedName

from poetry.core.packages.package import Package


class Metadata:
metadata_version = "2.1"
# version 1.0
name: NormalizedName | None = None
name: str | None = None
version: str
platforms: tuple[str, ...] = ()
supported_platforms: tuple[str, ...] = ()
Expand Down Expand Up @@ -51,7 +49,7 @@ def from_package(cls, package: Package) -> Metadata:

meta = cls()

meta.name = package.name
meta.name = package.pretty_name
meta.version = package.version.to_string()
meta.summary = package.description
if package.readmes:
Expand Down
2 changes: 2 additions & 0 deletions tests/masonry/builders/fixtures/Pretty.Name/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Pretty.Name
===========
1 change: 1 addition & 0 deletions tests/masonry/builders/fixtures/Pretty.Name/pretty_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Example module"""
12 changes: 12 additions & 0 deletions tests/masonry/builders/fixtures/Pretty.Name/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.poetry]
name = "Pretty.Name"
version = "1.0"
description = "Some description."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
]
license = "MIT"

readme = "README.rst"

homepage = "https://python-poetry.org/"
10 changes: 10 additions & 0 deletions tests/masonry/builders/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ def test_get_metadata_content() -> None:
]


def test_metadata_pretty_name() -> None:
builder = Builder(
Factory().create_poetry(Path(__file__).parent / "fixtures" / "Pretty.Name")
)

metadata = Parser().parsestr(builder.get_metadata_content())

assert metadata["Name"] == "Pretty.Name"


def test_metadata_homepage_default() -> None:
builder = Builder(
Factory().create_poetry(Path(__file__).parent / "fixtures" / "simple_version")
Expand Down
Loading