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.

Adding a check for file in convert cli. Earliar it used to raise long error (#4022)

xeniumf75543d4c533
diff --git a/marimo/_cli/convert/commands.py b/marimo/_cli/convert/commands.py
index fe4134eedb..da845f688d 100644
--- a/marimo/_cli/convert/commands.py
+++ b/marimo/_cli/convert/commands.py
@@ -50,6 +50,7 @@ def convert(
you may need to fix errors like multiple definition errors or cycle
errors.
"""
+
ext = Path(filename).suffix
if ext not in (".ipynb", ".md", ".qmd"):
raise click.UsageError("File must be an .ipynb or .md file")
diff --git a/marimo/_cli/convert/utils.py b/marimo/_cli/convert/utils.py
index bcf6f9ffab..22848f8ca2 100644
--- a/marimo/_cli/convert/utils.py
+++ b/marimo/_cli/convert/utils.py
@@ -4,6 +4,8 @@ from __future__ import annotations
import urllib.request
from pathlib import Path
+import click
+
from marimo._cli.file_path import get_github_src_url, is_github_src
from marimo._utils.url import is_url
@@ -19,6 +21,8 @@ def load_external_file(file_path: str, ext: str) -> str:
elif is_url(file_path):
notebook = urllib.request.urlopen(file_path).read().decode("utf-8")
else:
+ if not Path(file_path).exists():
+ raise click.FileError(file_path, "File does not exist")
notebook = Path(file_path).read_text(encoding="utf-8")
return notebook