Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Helpful error for marimo edit foo.ipynb (#393)

Akshay Agrawal6efd8a9a1f9e
diff --git a/marimo/_cli/file_path.py b/marimo/_cli/file_path.py
index b01c2459b1..eb41a8b141 100644
--- a/marimo/_cli/file_path.py
+++ b/marimo/_cli/file_path.py
@@ -12,6 +12,7 @@ from typing import Optional
import click
+from marimo._cli.print import green
from marimo._utils.url import is_url
@@ -59,7 +60,15 @@ def validate_name(
return _handle_github_issue(name, temp_dir), temp_dir
path = pathlib.Path(name)
- if path.suffix != ".py":
+ if path.suffix == ".ipynb":
+ prefix = str(path)[: -len(".ipynb")]
+ raise click.UsageError(
+ f"Invalid NAME - {name} is not a Python file.\n\n"
+ f" {green('Tip:')} Convert {name} to a marimo notebook with\n\n"
+ f" marimo convert {name} > {prefix}.py\n\n"
+ f" then open with marimo edit {prefix}.py"
+ )
+ elif path.suffix != ".py":
raise click.UsageError("Invalid NAME - %s is not a Python file" % name)
if is_github_src(name, ext=".py"):