Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 19, 2024
1 parent 2083eda commit 3dbc1dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,17 @@ def create_notebook(outline):
follows_code_cell = merged_cells and merged_cells[-1]["cell_type"] == "code"
is_incomplete = cell["cell_type"] == "code" and cell["source"].startswith(" ")
if follows_code_cell and is_incomplete:
merged_cells[-1]["source"] = merged_cells[-1]["source"] + "\n\n" + cell["source"]
merged_cells[-1]["source"] = (
merged_cells[-1]["source"] + "\n\n" + cell["source"]
)
else:
merged_cells.append(cell)

# Fix code cells that should be markdown
for j in range(len(merged_cells)):
if merged_cells[j]["cell_type"]=="code" and is_not_python_code(merged_cells[j]["source"]):
if merged_cells[j]["cell_type"] == "code" and is_not_python_code(
merged_cells[j]["source"]
):
merged_cells[j]["cell_type"] = "markdown"

nb["cells"] = merged_cells
Expand Down

0 comments on commit 3dbc1dc

Please sign in to comment.