Skip to content

Commit 8718681

Browse files
authored
Don't allow trailing newlines in description (#505)
1 parent 155fa0d commit 8718681

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/poetry/core/json/schemas/poetry-schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"description": {
2222
"type": "string",
2323
"description": "Short package description.",
24-
"pattern": "^[^\n]*$"
24+
"pattern": "\\A[^\n]*\\Z"
2525
},
2626
"keywords": {
2727
"type": "array",

tests/json/test_poetry_schema.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ def test_multi_url_dependencies(multi_url_object: dict[str, Any]) -> None:
5050
assert len(validate_object(multi_url_object, "poetry-schema")) == 0
5151

5252

53-
def test_multiline_description(base_object: dict[str, Any]) -> None:
54-
bad_description = "Some multi-\nline string"
53+
@pytest.mark.parametrize(
54+
"bad_description",
55+
["Some multi-\nline string", "Some multiline string\n", "\nSome multi-line string"],
56+
)
57+
def test_multiline_description(
58+
base_object: dict[str, Any], bad_description: str
59+
) -> None:
5560
base_object["description"] = bad_description
5661

5762
errors = validate_object(base_object, "poetry-schema")
63+
5864
assert len(errors) == 1
59-
assert errors[0] == f"[description] {bad_description!r} does not match '^[^\\n]*$'"
65+
66+
regex = r"\\A[^\n]*\\Z"
67+
assert errors[0] == f"[description] {bad_description!r} does not match '{regex}'"

0 commit comments

Comments
 (0)