Skip to content

Commit 34d7364

Browse files
ischaojieofek
andauthored
Normaliza metadata the description field when contain line break (#794)
* Normaliza metadata the description field when contain line break * Apply suggestions from code review --------- Co-authored-by: Ofek Lev <[email protected]>
1 parent c1e7a69 commit 34d7364

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

backend/src/hatchling/metadata/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ def description(self) -> str:
462462
if not isinstance(description, str):
463463
message = 'Field `project.description` must be a string'
464464
raise TypeError(message)
465-
466-
self._description = description
465+
self._description = ' '.join(description.splitlines())
467466

468467
return self._description
469468

tests/backend/metadata/test_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ def test_custom(self, isolation):
338338

339339
assert metadata.core.description == metadata.core.description == 'foo'
340340

341+
def test_normaliza(self, isolation):
342+
metadata = ProjectMetadata(str(isolation), None, {'project': {'description': '\nfirst line.\r\nsecond line'}})
343+
344+
assert metadata.core.description == metadata.core.description == ' first line. second line'
345+
341346

342347
class TestReadme:
343348
def test_dynamic(self, isolation):

0 commit comments

Comments
 (0)