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.

chore: remove importing directly from marimo (#6780)

Myles Scolnickbfa682f0ba1c
diff --git a/marimo/_output/formatters/sympy_formatters.py b/marimo/_output/formatters/sympy_formatters.py
index cad1fbcd63..b6438ee035 100644
--- a/marimo/_output/formatters/sympy_formatters.py
+++ b/marimo/_output/formatters/sympy_formatters.py
@@ -8,9 +8,7 @@ from marimo._output.formatters.formatter_factory import FormatterFactory
def patch_sympy(*objs: Any) -> None:
- import marimo as mo
-
- """adds the _mime_() method to sympy objects
+ """Adds the _mime_() method to sympy objects
e.g.
Symbol._mime_ = sympy_html
example:
@@ -18,26 +16,29 @@ def patch_sympy(*objs: Any) -> None:
"""
from sympy import latex # type: ignore
+ from marimo._output.md import md
+
for obj in objs:
# the lambda below is our sympy_html
obj._mime_ = lambda obj: (
"text/html",
- mo.md(f"""\\[{latex(obj)}\\]""").text,
+ md(f"""\\[{latex(obj)}\\]""").text,
)
def sympy_as_html(obj: Any) -> tuple[KnownMimeType, str]:
- from sympy import latex
-
- import marimo as mo
-
- """creates HTML output from a Printable Sympy object
+ """Creates HTML output from a Printable Sympy object
e.g.
- example:
+
+ Example:
integral = Integral(x**2, x)
sympy_as_html(integral)
"""
- return ("text/html", mo.md(f"""\\[{latex(obj)}\\]""").text)
+ from sympy import latex
+
+ from marimo._output.md import md
+
+ return ("text/html", md(f"""\\[{latex(obj)}\\]""").text)
class SympyFormatter(FormatterFactory):
diff --git a/marimo/_runtime/marimo_browser.py b/marimo/_runtime/marimo_browser.py
index cfe9165373..2470b06da5 100644
--- a/marimo/_runtime/marimo_browser.py
+++ b/marimo/_runtime/marimo_browser.py
@@ -17,7 +17,9 @@ def browser_open_fallback(
"""
import inspect
- import marimo as mo
+ import marimo._runtime.output._output as output
+ from marimo._output.hypertext import Html
+ from marimo._plugins.stateless.image import image
del new, autoraise # unused
@@ -44,8 +46,8 @@ def browser_open_fallback(
stack[2].filename.endswith("antigravity.py")
or (stack[1].filename.endswith("antigravity.py"))
):
- mo.output.append(
- mo.image(
+ output.append(
+ image(
"https://marimo.app/images/antigravity.png",
alt=(
"The image shows 2 stick figures in XKCD style. The one "
@@ -67,8 +69,8 @@ def browser_open_fallback(
)
)
else:
- mo.output.append(
- mo.Html(
+ output.append(
+ Html(
f"<iframe src='{url}' style='width:100%;height:500px'></iframe>",
)
)
diff --git a/marimo/_runtime/pytest.py b/marimo/_runtime/pytest.py
index 3a46bbb684..24af1f8282 100644
--- a/marimo/_runtime/pytest.py
+++ b/marimo/_runtime/pytest.py
@@ -7,12 +7,13 @@ import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Callable, Optional
-import marimo
+from marimo._ast.cell import Cell
from marimo._ast.pytest import MARIMO_TEST_STUB_NAME
from marimo._cli.print import bold, green
from marimo._dependencies.dependencies import DependencyManager
from marimo._runtime.capture import capture_stdout
from marimo._runtime.context import safe_get_context
+from marimo._runtime.runtime import notebook_location
MARIMO_TEST_BLOCK_REGEX = re.compile(rf"{MARIMO_TEST_STUB_NAME}_\d+[(?::)\.]+")
@@ -60,7 +61,7 @@ def _to_marimo_uri(uri: str) -> str:
return uri
cell_id = uri.split("_")[6]
- notebook = os.path.relpath(_get_name(), marimo.notebook_location())
+ notebook = os.path.relpath(_get_name(), notebook_location())
return f"marimo://{notebook}#cell_id={cell_id}"
@@ -69,7 +70,7 @@ def _sub_function(
) -> _pytest.Item:
# Directly execute the cell, since this means it's a toplevel function with no deps.
# Or a cell where which we already wrapped in skip.
- if isinstance(old_item.obj, marimo._ast.cell.Cell):
+ if isinstance(old_item.obj, Cell):
return old_item
import pytest # type: ignore
diff --git a/tests/_cli/test_file_path.py b/tests/_cli/test_file_path.py
index 4556459c5b..43dce90d84 100644
--- a/tests/_cli/test_file_path.py
+++ b/tests/_cli/test_file_path.py
@@ -9,7 +9,6 @@ from unittest.mock import Mock, patch
import click
import pytest
-from docs.blocks import uri_encode_component
from marimo._cli.file_path import (
FileContentReader,
GenericURLReader,
@@ -23,6 +22,7 @@ from marimo._cli.file_path import (
is_github_src,
validate_name,
)
+from marimo._output.utils import uri_encode_component
from marimo._utils.requests import Response
from tests.mocks import EDGE_CASE_FILENAMES