From 7499fec837ad5139211b832d8f79f0e3efeab6d3 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Sun, 27 Oct 2024 19:47:30 +0100 Subject: [PATCH 1/5] add override for EPL-2.0 as SPDX does not include a name recognized by pypi.org --- src/poetry/core/spdx/license.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/poetry/core/spdx/license.py b/src/poetry/core/spdx/license.py index e10ad6b8f..f85326c69 100644 --- a/src/poetry/core/spdx/license.py +++ b/src/poetry/core/spdx/license.py @@ -107,6 +107,7 @@ class License(namedtuple("License", "id name is_osi_approved is_deprecated")): "CECILL-2.1": "CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)", "CPL-1.0": "Common Public License", "EPL-1.0": "Eclipse Public License 1.0 (EPL-1.0)", + "EPL-2.0": "Eclipse Public License 2.0 (EPL-2.0)", "EFL-1.0": "Eiffel Forum License", "EFL-2.0": "Eiffel Forum License", "EUPL-1.1": "European Union Public Licence 1.1 (EUPL 1.1)", From a6a80c68a6898f58b4c79929d57180700d341bdc Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 28 Oct 2024 08:03:45 +0100 Subject: [PATCH 2/5] chore: add unit test to ensure that all classifiers are valid trove classifiers, add trove_classifier as test dependency, fix Aladdin license --- poetry.lock | 14 ++++++++++++-- pyproject.toml | 1 + src/poetry/core/spdx/license.py | 1 + tests/spdx/test_helpers.py | 13 ++++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 17e78027c..7d2ef5da6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -691,7 +691,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -938,6 +937,17 @@ files = [ {file = "tomli_w-1.0.0.tar.gz", hash = "sha256:f463434305e0336248cac9c2dc8076b707d8a12d019dd349f5c1e382dd1ae1b9"}, ] +[[package]] +name = "trove-classifiers" +version = "2024.10.21.16" +description = "Canonical source for classifiers on PyPI (pypi.org)." +optional = false +python-versions = "*" +files = [ + {file = "trove_classifiers-2024.10.21.16-py3-none-any.whl", hash = "sha256:0fb11f1e995a757807a8ef1c03829fbd4998d817319abcef1f33165750f103be"}, + {file = "trove_classifiers-2024.10.21.16.tar.gz", hash = "sha256:17cbd055d67d5e9d9de63293a8732943fabc21574e4c7b74edf112b4928cf5f3"}, +] + [[package]] name = "types-setuptools" version = "71.0.0.20240722" @@ -1038,4 +1048,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "f735bca440c1c1eeba822e475315a9c86fcb2cbb4f9aa3cd6920527cb9a5a55d" +content-hash = "8f807e88a8c6ee08a86815c861a106f7a7dba5e2e744f056a90748676a4b3bec" diff --git a/pyproject.toml b/pyproject.toml index 0955463c6..447e9e554 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ build = ">=0.10.0" setuptools = ">=60" tomli-w = "^1.0.0" virtualenv = ">=20.21" +trove-classifiers = ">=2022.5.19" [tool.poetry.group.typing.dependencies] mypy = ">=1.0" diff --git a/src/poetry/core/spdx/license.py b/src/poetry/core/spdx/license.py index f85326c69..7f1a0119d 100644 --- a/src/poetry/core/spdx/license.py +++ b/src/poetry/core/spdx/license.py @@ -77,6 +77,7 @@ class License(namedtuple("License", "id name is_osi_approved is_deprecated")): CLASSIFIER_NAMES: ClassVar[dict[str, str]] = { # Not OSI Approved + "Aladdin": "Aladdin Free Public License (AFPL)", "AFPL": "Aladdin Free Public License (AFPL)", "CC0-1.0": "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "CECILL-B": "CeCILL-B Free Software License Agreement (CECILL-B)", diff --git a/tests/spdx/test_helpers.py b/tests/spdx/test_helpers.py index add838d9f..5de3d3eb1 100644 --- a/tests/spdx/test_helpers.py +++ b/tests/spdx/test_helpers.py @@ -2,7 +2,7 @@ import pytest -from poetry.core.spdx.helpers import license_by_id +from poetry.core.spdx.helpers import license_by_id, _load_licenses def test_license_by_id() -> None: @@ -52,3 +52,14 @@ def test_license_by_id_custom() -> None: assert license.name == "Custom" assert not license.is_osi_approved assert not license.is_deprecated + + +def test_valid_trove_classifiers() -> None: + import trove_classifiers + + licenses = _load_licenses() + + for license_id, license in licenses.items(): + classifier = license.classifier + + assert classifier in trove_classifiers.classifiers From 2e67fee901da8795a752adaa6b9a0f8dbc90f22d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 07:04:15 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/spdx/test_helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/spdx/test_helpers.py b/tests/spdx/test_helpers.py index 5de3d3eb1..c9fb8c885 100644 --- a/tests/spdx/test_helpers.py +++ b/tests/spdx/test_helpers.py @@ -2,7 +2,8 @@ import pytest -from poetry.core.spdx.helpers import license_by_id, _load_licenses +from poetry.core.spdx.helpers import _load_licenses +from poetry.core.spdx.helpers import license_by_id def test_license_by_id() -> None: From 715e217943709b98ee5d6a326b8568fa0c6cd61a Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 28 Oct 2024 08:19:37 +0100 Subject: [PATCH 4/5] improve test in case an assertion fails --- tests/spdx/test_helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/spdx/test_helpers.py b/tests/spdx/test_helpers.py index c9fb8c885..96d9ae716 100644 --- a/tests/spdx/test_helpers.py +++ b/tests/spdx/test_helpers.py @@ -62,5 +62,6 @@ def test_valid_trove_classifiers() -> None: for license_id, license in licenses.items(): classifier = license.classifier - - assert classifier in trove_classifiers.classifiers + valid_classifier = classifier in trove_classifiers.classifiers + + assert valid_classifier, f"'{license_id}' returns invalid classifier '{classifier}'" From 752dfb0e636e7e59ee89a57115174af96d37fb6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 07:19:48 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/spdx/test_helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/spdx/test_helpers.py b/tests/spdx/test_helpers.py index 96d9ae716..e660d8854 100644 --- a/tests/spdx/test_helpers.py +++ b/tests/spdx/test_helpers.py @@ -63,5 +63,7 @@ def test_valid_trove_classifiers() -> None: for license_id, license in licenses.items(): classifier = license.classifier valid_classifier = classifier in trove_classifiers.classifiers - - assert valid_classifier, f"'{license_id}' returns invalid classifier '{classifier}'" + + assert ( + valid_classifier + ), f"'{license_id}' returns invalid classifier '{classifier}'"