From 09b3e878338454a059b6ac377f25e411506342ca Mon Sep 17 00:00:00 2001 From: johnthagen Date: Sat, 31 Dec 2022 11:08:37 -0500 Subject: [PATCH 1/3] Support Private trove classifiers --- src/poetry/console/commands/check.py | 4 ++++ tests/console/commands/test_check.py | 18 ++++++++++++++++++ .../fixtures/private_pyproject/pyproject.toml | 17 +++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/fixtures/private_pyproject/pyproject.toml diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py index 30812883523..197e8d64c35 100644 --- a/src/poetry/console/commands/check.py +++ b/src/poetry/console/commands/check.py @@ -33,6 +33,10 @@ def validate_classifiers( unrecognized = sorted( project_classifiers - set(classifiers) - set(deprecated_classifiers) ) + # Allow "Private ::" classifiers as recommended on PyPI and the packaging guide to allow + # users to avoid accidentally publishing private packages to PyPI. + # https://pypi.org/classifiers/ + unrecognized = [u for u in unrecognized if not u.startswith("Private ::")] if unrecognized: errors.append(f"Unrecognized classifiers: {unrecognized!r}.") diff --git a/tests/console/commands/test_check.py b/tests/console/commands/test_check.py index 1c21a80f3e5..247eca67ace 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -54,3 +54,21 @@ def test_check_invalid(mocker: MockerFixture, tester: CommandTester): """ assert tester.io.fetch_error() == expected + + +def test_check_private(mocker: MockerFixture, tester: CommandTester): + mocker.patch( + "poetry.factory.Factory.locate", + return_value=Path(__file__).parent.parent.parent + / "fixtures" + / "private_pyproject" + / "pyproject.toml", + ) + + tester.execute() + + expected = """\ +All set! +""" + + assert tester.io.fetch_error() == expected diff --git a/tests/fixtures/private_pyproject/pyproject.toml b/tests/fixtures/private_pyproject/pyproject.toml new file mode 100644 index 00000000000..a572e83c8ff --- /dev/null +++ b/tests/fixtures/private_pyproject/pyproject.toml @@ -0,0 +1,17 @@ +[tool.poetry] +name = "private" +version = "0.1.0" +description = "" +authors = ["Your Name "] +readme = "README.md" +classifiers = [ + "Private :: Do Not Upload", +] + + +[tool.poetry.dependencies] +python = "^3.7" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" From 7689bfa38e00c3f2ce5c3c014378d6f61725e4a5 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Sat, 31 Dec 2022 11:11:45 -0500 Subject: [PATCH 2/3] Fix long line length --- src/poetry/console/commands/check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py index 197e8d64c35..c64669956a6 100644 --- a/src/poetry/console/commands/check.py +++ b/src/poetry/console/commands/check.py @@ -33,8 +33,8 @@ def validate_classifiers( unrecognized = sorted( project_classifiers - set(classifiers) - set(deprecated_classifiers) ) - # Allow "Private ::" classifiers as recommended on PyPI and the packaging guide to allow - # users to avoid accidentally publishing private packages to PyPI. + # Allow "Private ::" classifiers as recommended on PyPI and the packaging guide + # to allow users to avoid accidentally publishing private packages to PyPI. # https://pypi.org/classifiers/ unrecognized = [u for u in unrecognized if not u.startswith("Private ::")] if unrecognized: From c2fe923d24e428a6900be0ca68a1905eb145528f Mon Sep 17 00:00:00 2001 From: johnthagen Date: Sat, 31 Dec 2022 12:31:06 -0500 Subject: [PATCH 3/3] Fix fetch_output test method usage --- tests/console/commands/test_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/console/commands/test_check.py b/tests/console/commands/test_check.py index 247eca67ace..e6e259cb5bf 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -71,4 +71,4 @@ def test_check_private(mocker: MockerFixture, tester: CommandTester): All set! """ - assert tester.io.fetch_error() == expected + assert tester.io.fetch_output() == expected