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
chore(ruff): standardize optional union ordering (#10845)
Shahmir Varqhafe5178378062
diff --git a/marimo/_ast/pytest.py b/marimo/_ast/pytest.pyindex cfbe0a9d93..51693937a9 100644--- a/marimo/_ast/pytest.py+++ b/marimo/_ast/pytest.py@@ -40,8 +40,8 @@ def _pytest_scaffold(stub: Any) -> Any:def build_stub_fn(func_body: ast.FunctionDef | ast.AsyncFunctionDef,file: str = "",- basis: None | Callable[..., Any] = None,- allowed: None | list[str] = None,+ basis: Callable[..., Any] | None = None,+ allowed: list[str] | None = None,) -> Callable[..., Any]:# Avoid declaring the function in the global scope, since it may cause# issues with meta-analysis tools like cxfreeze (see #3828).diff --git a/marimo/_lint/diagnostic.py b/marimo/_lint/diagnostic.pyindex 61dc099ab5..8d13d46aa9 100644--- a/marimo/_lint/diagnostic.py+++ b/marimo/_lint/diagnostic.py@@ -29,7 +29,7 @@ class Diagnostic:message: strline: int | list[int]column: int | list[int]- cell_id: None | list[CellId_t] = None+ cell_id: list[CellId_t] | None = Nonecode: str | None = Nonename: str | None = Noneseverity: Severity | None = Nonediff --git a/marimo/_messaging/notification.py b/marimo/_messaging/notification.pyindex 3e05373e64..fb0bcf2800 100644--- a/marimo/_messaging/notification.py+++ b/marimo/_messaging/notification.py@@ -112,7 +112,7 @@ class CellNotification(Notification, tag="cell-op"):# Tri-state partial update: UNSET (omitted on the wire) leaves the cell's# serialization hint unchanged; None explicitly clears it (cell is no# longer a top-level definition); a string sets it.- serialization: str | None | msgspec.UnsetType = msgspec.UNSET+ serialization: str | msgspec.UnsetType | None = msgspec.UNSETtimestamp: float = msgspec.field(default_factory=lambda: time.time())def __post_init__(self) -> None:diff --git a/marimo/_output/formatters/structures.py b/marimo/_output/formatters/structures.pyindex df5dcabb79..ae6123ecea 100644--- a/marimo/_output/formatters/structures.py+++ b/marimo/_output/formatters/structures.py@@ -94,7 +94,7 @@ def _escape_fallback(s: str) -> str:def _leaf_formatter(value: object,-) -> bool | None | str | int:+) -> bool | str | int | None:formatter = formatting.get_formatter(value)# Because we don't flatten subclasses of structures, we need to avoiddiff --git a/marimo/_runtime/dataflow/graph.py b/marimo/_runtime/dataflow/graph.pyindex bed6ae3e17..8ec90cb0d5 100644--- a/marimo/_runtime/dataflow/graph.py+++ b/marimo/_runtime/dataflow/graph.py@@ -374,7 +374,7 @@ class DirectedGraph(GraphTopology):return processed | refsreturn processed - refs- def copy(self, filename: None | str = None) -> DirectedGraph:+ def copy(self, filename: str | None = None) -> DirectedGraph:"""Return a deep copy of the graph by recompiling all cells.This is mainly useful in the case where recompilation must be donediff --git a/marimo/_runtime/packages/import_error_extractors.py b/marimo/_runtime/packages/import_error_extractors.pyindex 4d075ac0bc..ff7486d972 100644--- a/marimo/_runtime/packages/import_error_extractors.py+++ b/marimo/_runtime/packages/import_error_extractors.py@@ -12,7 +12,7 @@ def extract_missing_module_from_cause_chain(This handles cases where a `ModuleNotFoundError` was raised and then wrapped,e.g., via `raise ImportError("helpful message") from err`"""- current: None | BaseException = error+ current: BaseException | None = errorwhile current is not None:if (isinstance(current, ModuleNotFoundError)diff --git a/marimo/_save/loaders/lazy.py b/marimo/_save/loaders/lazy.pyindex 17e4e6ec41..3f99da329c 100644--- a/marimo/_save/loaders/lazy.py+++ b/marimo/_save/loaders/lazy.py@@ -615,8 +615,8 @@ class LazyLoader(BasePersistenceLoader):self,name: str,store: Store | None = None,- signer: CacheSigner | None | _Unset = _SIGNER_UNSET,- trusted_signers: Iterable[str] | None | _Unset = _TRUSTED_UNSET,+ signer: CacheSigner | _Unset | None = _SIGNER_UNSET,+ trusted_signers: Iterable[str] | _Unset | None = _TRUSTED_UNSET,verification: str | _Unset = _VERIFICATION_UNSET,) -> None:"""Create a LazyLoader.@@ -847,7 +847,7 @@ class LazyLoader(BasePersistenceLoader):return self._signer@signer.setter- def signer(self, value: CacheSigner | None | _Unset) -> None:+ def signer(self, value: CacheSigner | _Unset | None) -> None:# Validate up front (mirrors __init__) so a bad reconfigure fails here# rather than as an AttributeError mid-save.if not isinstance(value, (_Unset, CacheSigner)) and value is not None:diff --git a/marimo/_schemas/export.py b/marimo/_schemas/export.pyindex 1917a5793f..c8d6179ed9 100644--- a/marimo/_schemas/export.py+++ b/marimo/_schemas/export.py@@ -36,7 +36,7 @@ class ExportAsHTMLRequest(msgspec.Struct, rename="camel"):files: list[str]include_code: boolasset_url: str | None = None- layout: LayoutConfig | None | msgspec.UnsetType = msgspec.UNSET+ layout: LayoutConfig | msgspec.UnsetType | None = msgspec.UNSETdef to_html_export_options(diff --git a/marimo/_server/ai/mcp/types.py b/marimo/_server/ai/mcp/types.pyindex 76dd831029..24751c8d7c 100644--- a/marimo/_server/ai/mcp/types.py+++ b/marimo/_server/ai/mcp/types.py@@ -8,8 +8,8 @@ MCPToolValue: TypeAlias = (| int| float| bool- | None| list["MCPToolValue"]| dict[str, "MCPToolValue"]+ | None)MCPToolArgs: TypeAlias = dict[str, MCPToolValue] | Nonediff --git a/marimo/_utils/env.py b/marimo/_utils/env.pyindex c416dad1e6..8ba8316c7a 100644--- a/marimo/_utils/env.py+++ b/marimo/_utils/env.py@@ -16,7 +16,7 @@ def is_env_true(key: str, default: bool = False) -> bool:return value.strip().lower() in ("true", "1")-def env_to_value(key: str) -> tuple[str | None | list[str] | bool] | None:+def env_to_value(key: str) -> tuple[str | list[str] | bool | None] | None:"""Return a typed value from environment variables."""if key in os.environ:value = os.environ[key]diff --git a/marimo/_utils/lists.py b/marimo/_utils/lists.pyindex 4e1f6db9cd..4f04a606ce 100644--- a/marimo/_utils/lists.py+++ b/marimo/_utils/lists.py@@ -14,7 +14,7 @@ def first(iterable: Iterable[T] | T) -> T:return iterable-def as_list(value: T | None | list[T]) -> list[T]:+def as_list(value: T | list[T] | None) -> list[T]:if value is None:return []return value if isinstance(value, list) else [value] # type: ignore[no-any-return]diff --git a/pyproject.toml b/pyproject.tomlindex 9190f83a45..b48c047c62 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -389,7 +389,6 @@ ignore = ["FURB189", # Subclassing built-in collections"FURB152", # Replace literal with a math constant"FURB110", # Replace ternary with an `or` expression- "RUF036", # `None` is not last in a union"FURB113", # Repeated `append` calls"NPY002", # Legacy NumPy random API"RUF100", # Unused `noqa` directive