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

fix: workaround unsupported metadata version 2.4 in pkginfo #9881

Merged
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
5 changes: 4 additions & 1 deletion src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ def _from_distribution(

:param dist: The distribution instance to parse information from.
"""
if dist.metadata_version not in pkginfo.distribution.HEADER_ATTRS:
# The current pkginfo version (1.11.2) does not support 2.4.
# The fields we are interested in can be parsed nevertheless.
supported_metadata_versions = {*pkginfo.distribution.HEADER_ATTRS.keys(), "2.4"}
if dist.metadata_version not in supported_metadata_versions:
# This check can be replaced once upstream implements strict parsing
# https://bugs.launchpad.net/pkginfo/+bug/2058697
raise ValueError(f"Unknown metadata version: {dist.metadata_version}")
Expand Down
Binary file not shown.
7 changes: 5 additions & 2 deletions tests/inspection/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,13 @@ def test_info_from_wheel(demo_wheel: Path) -> None:
assert info._source_url == demo_wheel.resolve().as_posix()


def test_info_from_wheel_metadata_version_23(fixture_dir: FixtureDirGetter) -> None:
@pytest.mark.parametrize("version", ["23", "24"])
def test_info_from_wheel_metadata_versions(
version: str, fixture_dir: FixtureDirGetter
) -> None:
path = (
fixture_dir("distributions")
/ "demo_metadata_version_23-0.1.0-py2.py3-none-any.whl"
/ f"demo_metadata_version_{version}-0.1.0-py2.py3-none-any.whl"
)
info = PackageInfo.from_wheel(path)
demo_check_info(info)
Expand Down
Loading