diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index 08c7a7918b6..f30efcaefa5 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -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}") diff --git a/tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl b/tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl new file mode 100644 index 00000000000..4c8cf2f72b3 Binary files /dev/null and b/tests/fixtures/distributions/demo_metadata_version_24-0.1.0-py2.py3-none-any.whl differ diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index 776cafa60d1..b0cc6f1c3db 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -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)