From c1157102c378d5cc8251d32b8db66a42c66b00c5 Mon Sep 17 00:00:00 2001 From: yuji38kwmt Date: Wed, 3 May 2023 11:21:30 +0900 Subject: [PATCH 1/2] update package.py: unique python_classifiers --- src/poetry/core/packages/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/poetry/core/packages/package.py b/src/poetry/core/packages/package.py index 7a544fca5..bad40c088 100644 --- a/src/poetry/core/packages/package.py +++ b/src/poetry/core/packages/package.py @@ -348,7 +348,7 @@ def all_classifiers(self) -> list[str]: # it like this so that 3.10 is sorted after 3.9. sorted_classifiers = [] python_classifiers_inserted = False - for classifier in sorted(set(classifiers)): + for classifier in sorted(set(classifiers) - set(python_classifiers)): if ( not python_classifiers_inserted and classifier > python_classifier_prefix From dd9d40d95b2faf7f231ec195cc347c6343cff23b Mon Sep 17 00:00:00 2001 From: yuji38kwmt Date: Wed, 3 May 2023 11:48:12 +0900 Subject: [PATCH 2/2] add test code --- .../pyproject.toml | 20 +++++++++++++++++++ tests/test_factory.py | 16 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/fixtures/project_with_duplicated_classifiers/pyproject.toml diff --git a/tests/fixtures/project_with_duplicated_classifiers/pyproject.toml b/tests/fixtures/project_with_duplicated_classifiers/pyproject.toml new file mode 100644 index 000000000..055b95a32 --- /dev/null +++ b/tests/fixtures/project_with_duplicated_classifiers/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "project_with_duplicated_classifiers" +version = "1.2.3" +description = "This is a description" +authors = ["Your Name "] +license = "MIT" + +classifiers = [ + # Duplicated classifiers + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Build Tools", + # The following classifiers are automatically generated + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] + +[tool.poetry.dependencies] +python = "^3.8" diff --git a/tests/test_factory.py b/tests/test_factory.py index fb820df04..43f3c86aa 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -478,3 +478,19 @@ def test_create_dependency_marker_variants( assert dep.python_versions == exp_python assert dep.python_constraint == parse_constraint(exp_python) assert str(dep.marker) == exp_marker + + +def test_all_classifiers_unique_even_if_classifiers_is_duplicated() -> None: + poetry = Factory().create_poetry( + fixtures_dir / "project_with_duplicated_classifiers" + ) + package = poetry.package + assert package.all_classifiers == [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Software Development :: Build Tools", + ]