Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make missing long_description check more flexible.
A missing `long_description` results in `UNKNOWN` being written to
PKG-INFO, but at some point, the number of trailing newlines changed.

See
pypa/readme_renderer#231 (comment)
  • Loading branch information
bhrutledge committed Mar 26, 2022
commit cd9e29f435761259169098cfad88a175a9c29605
5 changes: 3 additions & 2 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ def test_check_passing_distribution_with_none_renderer(
assert capsys.readouterr().out == "Checking dist/dist.tar.gz: PASSED\n"


def test_check_no_description(monkeypatch, capsys, caplog):
@pytest.mark.parametrize("description", [None, "UNKNOWN\n\n", "UNKNOWN\n\n\n"])
def test_check_no_description(description, monkeypatch, capsys, caplog):
package = pretend.stub(
metadata_dictionary=lambda: {
"description": None,
"description": description,
"description_content_type": None,
}
)
Expand Down
2 changes: 1 addition & 1 deletion twine/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _check_file(
content_type, params = cgi.parse_header(description_content_type)
renderer = _RENDERERS.get(content_type, _RENDERERS[None])

if description in {None, "UNKNOWN\n\n\n"}:
if description is None or description.rstrip("\n") == "UNKNOWN":
warnings.append("`long_description` missing.")
elif renderer:
rendering_result = renderer.render(
Expand Down