Skip to content

Commit

Permalink
Remove output trailing newline
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Apr 18, 2024
1 parent b62ebfd commit ee00262
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions plugins/kernels/fps_kernels/kernel_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
if msg_type == "stream":
with outputs.doc.transaction():
# TODO: uncomment when changes are made in jupyter-ydoc
text = content["text"]
if text.endswith(os.linesep):
text = text[:-1]
if (not outputs) or (outputs[-1]["name"] != content["name"]): # type: ignore
outputs.append(
#Map(
Expand All @@ -235,13 +238,13 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
{
"name": content["name"],
"output_type": msg_type,
"text": [content["text"]],
"text": [text],
}
)
else:
#outputs[-1]["text"].append(content["text"]) # type: ignore
last_output = outputs[-1]
last_output["text"].append(content["text"]) # type: ignore
last_output["text"].append(text) # type: ignore
outputs[-1] = last_output
elif msg_type in ("display_data", "execute_result"):
if "application/vnd.jupyter.ywidget-view+json" in content["data"]:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def test_rest_api(start_jupyverse):
}
]
assert cells[1]["outputs"] == [
{"name": "stdout", "output_type": "stream", "text": ["Hello World!\n"]}
{"name": "stdout", "output_type": "stream", "text": ["Hello World!"]}
]
assert cells[2]["outputs"] == [
{
Expand Down

0 comments on commit ee00262

Please sign in to comment.