diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index 7b28239f..46380970 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -133,7 +133,7 @@ class RawMetadata(TypedDict, total=False): # Metadata 2.4 - PEP 639 license_expression: str - license_file: list[str] + license_files: list[str] _STRING_FIELDS = { @@ -157,7 +157,7 @@ class RawMetadata(TypedDict, total=False): _LIST_FIELDS = { "classifiers", "dynamic", - "license_file", + "license_files", "obsoletes", "obsoletes_dist", "platforms", @@ -261,7 +261,7 @@ def _get_payload(msg: email.message.Message, source: bytes | str) -> str: "keywords": "keywords", "license": "license", "license-expression": "license_expression", - "license-file": "license_file", + "license-file": "license_files", "maintainer": "maintainer", "maintainer-email": "maintainer_email", "metadata-version": "metadata_version", @@ -655,7 +655,7 @@ def _process_license_expression(self, value: str) -> str: f"{value!r} is invalid for {{field}}", cause=exc ) from exc - def _process_license_file(self, value: list[str]) -> list[str]: + def _process_license_files(self, value: list[str]) -> list[str]: paths = [] for path in value: if ".." in path: @@ -805,7 +805,7 @@ def from_email(cls, data: bytes | str, *, validate: bool = True) -> Metadata: """:external:ref:`core-metadata-license`""" license_expression: _Validator[str | None] = _Validator(added="2.4") """:external:ref:`core-metadata-license-expression`""" - license_file: _Validator[list[str] | None] = _Validator(added="2.4") + license_files: _Validator[list[str] | None] = _Validator(added="2.4") """:external:ref:`core-metadata-license-file`""" classifiers: _Validator[list[str] | None] = _Validator(added="1.1") """:external:ref:`core-metadata-classifier`""" diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 22e7c70c..1a6e8330 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -216,7 +216,7 @@ def test_complete(self): " to redistribute it." ) assert raw["license_expression"] == "Apache-2.0 OR BSD-2-Clause" - assert raw["license_file"] == ["LICENSE.APACHE", "LICENSE.BSD"] + assert raw["license_files"] == ["LICENSE.APACHE", "LICENSE.BSD"] assert raw["classifiers"] == [ "Development Status :: 4 - Beta", "Environment :: Console (Text Based)", @@ -638,7 +638,7 @@ def test_invalid_license_expression(self): meta.license_expression # noqa: B018 @pytest.mark.parametrize( - "license_file", + "license_files", [ ["LICENSE.txt", "licenses/*"], [], @@ -646,24 +646,24 @@ def test_invalid_license_expression(self): ["LICENSE"], ], ) - def test_valid_license_file(self, license_file): + def test_valid_license_files(self, license_files): meta = metadata.Metadata.from_raw( - {"license_file": license_file}, validate=False + {"license_files": license_files}, validate=False ) - assert meta.license_file == license_file + assert meta.license_files == license_files @pytest.mark.parametrize( - "license_file", + "license_files", [ ["../LICENSE"], ["./../LICENSE"], ["licenses/../LICENSE"], ], ) - def test_invalid_license_file(self, license_file): + def test_invalid_license_files(self, license_files): meta = metadata.Metadata.from_raw( - {"license_file": license_file}, validate=False + {"license_files": license_files}, validate=False ) with pytest.raises(metadata.InvalidMetadata): - meta.license_file # noqa: B018 + meta.license_files # noqa: B018