Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion conda_recipe_manager/parser/recipe_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,9 @@ def _render_multiline_lst(n: Node) -> bool:
is_last_line = depth < 0 and child == node.children[-1]
if is_last_line and omit_trailing_newline:
return
if (is_cbc and is_last_line) or (not is_cbc and depth < 0 and not child.is_comment()):
if (is_cbc and is_last_line) or (
not is_cbc and depth < 0 and not child.is_comment() and (not lines or lines[-1] != "")
):
lines.append("")

def render(self, omit_trailing_newline: bool = False) -> str:
Expand Down
19 changes: 19 additions & 0 deletions tests/parser/test_recipe_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ def test_str(file: str, out_file: str) -> None:
assert not parser.is_modified()


def test_round_trip_multiline_string_before_next_section() -> None:
"""
Validates that a section separator after a multi-line string does not get captured as part of the string.
"""
content: Final[str] = (
"about:\n"
" summary: Example output 2\n"
" description: |\n"
" This is a test package for output2.\n"
"\n"
"extra:\n"
" recipe-maintainers:\n"
" - conda\n"
)
parser: Final = RecipeReader(content)

assert parser.render() == content


@pytest.mark.parametrize(
"file,other_file",
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ about:
GluonTS is a Python package for probabilistic time series modeling, focusing on deep learning based models, based
on PyTorch and MXNet.


extra:
recipe-maintainers:
- dkomisar
Loading