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
loosen typings for experimental config on the backend (#6138)
Shahmir Varqha548ec36412f7
diff --git a/marimo/_config/config.py b/marimo/_config/config.pyindex 87017e6f5b..1463c55a99 100644--- a/marimo/_config/config.py+++ b/marimo/_config/config.py@@ -513,6 +513,11 @@ class ExperimentalConfig(TypedDict, total=False):execution_type: ExecutionType+# Prefer to accept any dict since feature flags can change frequently+# But maintain type safety for known flags+ExperimentalConfigType = Union[dict[str, Any], ExperimentalConfig]++@mddoc@dataclassclass MarimoConfig(TypedDict):@@ -529,7 +534,7 @@ class MarimoConfig(TypedDict):ai: NotRequired[AiConfig]language_servers: NotRequired[LanguageServersConfig]diagnostics: NotRequired[DiagnosticsConfig]- experimental: NotRequired[ExperimentalConfig]+ experimental: NotRequired[ExperimentalConfigType]snippets: NotRequired[SnippetsConfig]datasources: NotRequired[DatasourcesConfig]sharing: NotRequired[SharingConfig]@@ -602,7 +607,7 @@ class PartialMarimoConfig(TypedDict, total=False):ai: NotRequired[AiConfig]language_servers: NotRequired[LanguageServersConfig]diagnostics: NotRequired[DiagnosticsConfig]- experimental: NotRequired[ExperimentalConfig]+ experimental: NotRequired[ExperimentalConfigType]snippets: SnippetsConfigdatasources: NotRequired[DatasourcesConfig]sharing: NotRequired[SharingConfig]diff --git a/marimo/_config/manager.py b/marimo/_config/manager.pyindex 3adb308eee..2d700b1c44 100644--- a/marimo/_config/manager.py+++ b/marimo/_config/manager.py@@ -11,7 +11,7 @@ from marimo import _loggersfrom marimo._config.config import (DEFAULT_CONFIG,CompletionConfig,- ExperimentalConfig,+ ExperimentalConfigType,ExportType,LanguageServersConfig,MarimoConfig,@@ -108,7 +108,7 @@ class MarimoConfigReader:return {}@property- def experimental(self) -> ExperimentalConfig:+ def experimental(self) -> ExperimentalConfigType:if "experimental" in self._config:return self._config["experimental"]return {}diff --git a/packages/openapi/api.yaml b/packages/openapi/api.yamlindex 08b92fc81f..8048373d68 100644--- a/packages/openapi/api.yaml+++ b/packages/openapi/api.yaml@@ -1623,44 +1623,47 @@ components:- default_table_max_columnstype: objectexperimental:- properties:- cache:- oneOf:- - items:- properties:- args:- additionalProperties: {}- type: object- type:- enum:- - file- - redis- - rest- - tiered- type: string- type: object- type: array- - $ref: '#/components/schemas/StoreConfig'- execution_type:- enum:- - relaxed- - strict- type: string- inline_ai_tooltip:- type: boolean- markdown:- type: boolean- mcp_docs:- type: boolean- performant_table_charts:- type: boolean- rtc_v2:- type: boolean- sql_linter:- type: boolean- wasm_layouts:- type: boolean- type: object+ oneOf:+ - additionalProperties: {}+ type: object+ - properties:+ cache:+ oneOf:+ - items:+ properties:+ args:+ additionalProperties: {}+ type: object+ type:+ enum:+ - file+ - redis+ - rest+ - tiered+ type: string+ type: object+ type: array+ - $ref: '#/components/schemas/StoreConfig'+ execution_type:+ enum:+ - relaxed+ - strict+ type: string+ inline_ai_tooltip:+ type: boolean+ markdown:+ type: boolean+ mcp_docs:+ type: boolean+ performant_table_charts:+ type: boolean+ rtc_v2:+ type: boolean+ sql_linter:+ type: boolean+ wasm_layouts:+ type: boolean+ type: objectformatting:properties:line_length:diff --git a/packages/openapi/src/api.ts b/packages/openapi/src/api.tsindex fd7a11c533..0fafd7672c 100644--- a/packages/openapi/src/api.ts+++ b/packages/openapi/src/api.ts@@ -3221,26 +3221,30 @@ export interface components {/** @enum {string} */theme: "light" | "dark" | "system";};- experimental?: {- cache?:- | {- args?: {- [key: string]: unknown;- };- /** @enum {string} */- type?: "file" | "redis" | "rest" | "tiered";- }[]- | components["schemas"]["StoreConfig"];- /** @enum {string} */- execution_type?: "relaxed" | "strict";- inline_ai_tooltip?: boolean;- markdown?: boolean;- mcp_docs?: boolean;- performant_table_charts?: boolean;- rtc_v2?: boolean;- sql_linter?: boolean;- wasm_layouts?: boolean;- };+ experimental?:+ | {+ [key: string]: unknown;+ }+ | {+ cache?:+ | {+ args?: {+ [key: string]: unknown;+ };+ /** @enum {string} */+ type?: "file" | "redis" | "rest" | "tiered";+ }[]+ | components["schemas"]["StoreConfig"];+ /** @enum {string} */+ execution_type?: "relaxed" | "strict";+ inline_ai_tooltip?: boolean;+ markdown?: boolean;+ mcp_docs?: boolean;+ performant_table_charts?: boolean;+ rtc_v2?: boolean;+ sql_linter?: boolean;+ wasm_layouts?: boolean;+ };formatting: {line_length: number;};diff --git a/tests/_utils/test_parse_dataclass.py b/tests/_utils/test_parse_dataclass.pyindex 5fc5385378..cd478f6c74 100644--- a/tests/_utils/test_parse_dataclass.py+++ b/tests/_utils/test_parse_dataclass.py@@ -19,6 +19,7 @@ from typing import (import pytest+from marimo._config.config import ExperimentalConfigTypefrom marimo._runtime.requests import SetCellConfigRequestfrom marimo._types.ids import CellId_tfrom marimo._utils.parse_dataclass import parse_raw@@ -280,6 +281,73 @@ class TestParseRaw:)assert "invalid" in str(e.value)+ def test_parse_raw_experimental_config_variants(self) -> None:+ """Test parse_raw with different variants of experimental config."""++ # Create a dataclass that contains the experimental field,+ # Similar to MarimoConfig and PartialMarimoConfig+ @dataclass+ class TestConfig:+ experimental: ExperimentalConfigType++ # Test 1: Known features+ structured_data = {+ "experimental": {"markdown": True, "cache": {"type": "redis"}}+ }++ parsed_structured = parse_raw(+ structured_data, TestConfig, allow_unknown_keys=True+ )+ assert parsed_structured.experimental["markdown"] is True+ assert parsed_structured.experimental["cache"]["type"] == "redis"++ # Test 1.5: Invalid values on known features+ invalid_data = {"experimental": {"markdown": "invalid"}}+ invalid = parse_raw(invalid_data, TestConfig)+ assert invalid.experimental["markdown"] == "invalid"++ # Test 2: Custom features+ dynamic_data = {+ "experimental": {+ "custom_feature": "custom_value",+ "another_flag": 42,+ "nested_config": {"key": "value"},+ "boolean_flag": True,+ }+ }++ parsed_dynamic = parse_raw(+ dynamic_data, TestConfig, allow_unknown_keys=True+ )+ assert parsed_dynamic.experimental["custom_feature"] == "custom_value"+ assert parsed_dynamic.experimental["another_flag"] == 42+ assert parsed_dynamic.experimental["nested_config"]["key"] == "value"+ assert parsed_dynamic.experimental["boolean_flag"] is True+ # Check not present field+ assert parsed_dynamic.experimental.get("mcp_docs") is None++ # Test 3: Mixed approach - known features + custom features+ mixed_data = {+ "experimental": {+ "markdown": True,+ "custom_feature": "mixed_value",+ "experimental_number": 123.45,+ "experimental_dict": {"nested": "value"},+ }+ }++ parsed_mixed = parse_raw(+ mixed_data, TestConfig, allow_unknown_keys=True+ )+ # Known features should work+ assert parsed_mixed.experimental["markdown"] is True+ # Custom features should also work+ assert parsed_mixed.experimental["custom_feature"] == "mixed_value"+ assert parsed_mixed.experimental["experimental_number"] == 123.45+ assert parsed_mixed.experimental["experimental_dict"] == {+ "nested": "value"+ }+def test_build_optional() -> None:@dataclass