Skip to content

Commit

Permalink
Support Private :: trove classifiers (#7271)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthagen committed Jan 20, 2023
1 parent 2d54ec9 commit 7279a07
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/poetry/console/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}.")

Expand Down
18 changes: 18 additions & 0 deletions tests/console/commands/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions tests/fixtures/private_pyproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "private"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
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"

0 comments on commit 7279a07

Please sign in to comment.