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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: comment only files count as empty files (#8289)
Dylan Madisettia4c69cb7ebbd
diff --git a/marimo/_ast/load.py b/marimo/_ast/load.pyindex f235368650..0b029ceb25 100644--- a/marimo/_ast/load.py+++ b/marimo/_ast/load.py@@ -121,9 +121,12 @@ def get_notebook_status(filename: str) -> LoadResult:if notebook is None:return LoadResult(status="empty", contents=contents)if not notebook.valid:- return LoadResult(- status="invalid", notebook=notebook, contents=contents- )+ if is_non_marimo_python_script(notebook):+ return LoadResult(+ status="invalid", notebook=notebook, contents=contents+ )+ # Only comments or a doc string — treat as empty per status definition+ return LoadResult(status="empty", notebook=notebook, contents=contents)if len(notebook.violations) > 0:LOGGER.debug("Notebook has violations: \n%s",diff --git a/tests/_ast/test_load.py b/tests/_ast/test_load.pyindex f091f4975b..50f600620d 100644--- a/tests/_ast/test_load.py+++ b/tests/_ast/test_load.py@@ -382,7 +382,7 @@ class TestGetStatus:# Empty files("test_empty", "empty"),# No cells- ("test_app_with_only_comments", "invalid"),+ ("test_app_with_only_comments", "empty"),# Invalid (not marimo apps)("test_invalid", "invalid"),# Has errors (hard violations — potential data loss)diff --git a/tests/_lint/test_run_check.py b/tests/_lint/test_run_check.pyindex a35c9d063e..6d93416068 100644--- a/tests/_lint/test_run_check.py+++ b/tests/_lint/test_run_check.py@@ -99,12 +99,9 @@ def __():md_result = next(f for f in result.files if f.file.endswith(".md"))txt_result = next(f for f in result.files if f.file.endswith(".txt"))- # py files with simple comments are not valid notebooks, so they fail parsing- assert py_result.failed is True # Not a valid notebook- # md files with simple content might be processed differently- assert (- md_result.failed is False or md_result.skipped is True- ) # Markdown files may be handled differently+ # files with simple comments are valid notebooks with errors.+ assert not py_result.failed+ assert not md_result.failedassert txt_result.skipped is True # Not a notebook