diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py index 12bfc09343f..8a53cd5bc09 100644 --- a/src/poetry/console/commands/check.py +++ b/src/poetry/console/commands/check.py @@ -31,6 +31,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 fcdfa5d9a19..dbf665b6227 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -59,3 +59,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_output() == 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"