Skip to content

Commit

Permalink
Make missing long_description check more flexible.
Browse files Browse the repository at this point in the history
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
1 parent a6dd69c commit cd9e29f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/test_check.py
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
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

0 comments on commit cd9e29f

Please sign in to comment.