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.

improvement: always show default value for CLI args (hide if default is None) (#8246)

Myles Scolnick04e893f80d86
diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.py
index aa7d39cbe9..540689d2eb 100644
--- a/marimo/_cli/cli.py
+++ b/marimo/_cli/cli.py
@@ -162,6 +162,7 @@ except Exception:
context_settings={
"help_option_names": ["-h", "--help"],
"max_content_width": MAX_TERM_WIDTH,
+ "show_default": True,
},
)
@click.version_option(version=__version__, message="%(version)s")
@@ -172,7 +173,6 @@ except Exception:
type=click.Choice(
["DEBUG", "INFO", "WARN", "ERROR", "CRITICAL"], case_sensitive=False
),
- show_default=True,
help="Choose logging level.",
)
@click.option(
@@ -180,7 +180,6 @@ except Exception:
"--quiet",
is_flag=True,
default=False,
- show_default=True,
help="Suppress standard out.",
)
@click.option(
@@ -188,7 +187,6 @@ except Exception:
"--yes",
is_flag=True,
default=False,
- show_default=True,
help="Automatic yes to prompts, running non-interactively.",
)
@click.option(
@@ -196,7 +194,6 @@ except Exception:
"--development-mode",
is_flag=True,
default=False,
- show_default=True,
help="Run in development mode; enables debug logs and server autoreload.",
)
def main(
@@ -266,14 +263,12 @@ edit_help_msg = "\n".join(
"-p",
"--port",
default=None,
- show_default=True,
type=int,
help="Port to attach to.",
)
@click.option(
"--host",
default="127.0.0.1",
- show_default=True,
type=str,
help="Host to attach to.",
)
@@ -287,35 +282,30 @@ edit_help_msg = "\n".join(
"--headless",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Don't launch a browser.",
)
@click.option(
"--token/--no-token",
default=True,
- show_default=True,
type=bool,
help=token_message,
)
@click.option(
"--token-password",
default=None,
- show_default=True,
type=str,
help=token_password_message,
)
@click.option(
"--token-password-file",
default=None,
- show_default=True,
type=str,
help="Path to file containing token password, or '-' for stdin. Mutually exclusive with --token-password.",
)
@click.option(
"--base-url",
default="",
- show_default=True,
type=str,
help="Base URL for the server. Should start with a /.",
callback=validators.base_url,
@@ -330,7 +320,6 @@ edit_help_msg = "\n".join(
"--skip-update-check",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Don't check if a new version of marimo is available for download.",
)
@@ -338,7 +327,6 @@ edit_help_msg = "\n".join(
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=sandbox_message,
)
@@ -346,7 +334,6 @@ edit_help_msg = "\n".join(
"--trusted/--untrusted",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help="Run notebooks hosted remotely on the host machine; if --untrusted, runs marimo in a Docker container.",
)
@@ -355,7 +342,6 @@ edit_help_msg = "\n".join(
"--watch",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Watch the file for changes and reload the code when saved in another editor.",
)
@@ -363,7 +349,6 @@ edit_help_msg = "\n".join(
"--skew-protection/--no-skew-protection",
is_flag=True,
default=True,
- show_default=True,
type=bool,
help="Enable skew protection middleware to prevent version mismatch issues.",
)
@@ -386,7 +371,6 @@ edit_help_msg = "\n".join(
"--mcp",
is_flag=True,
default=False,
- show_default=True,
type=bool,
hidden=True,
help="Enable MCP server endpoint at /mcp/server for LLM integration.",
@@ -409,14 +393,12 @@ edit_help_msg = "\n".join(
"--timeout",
required=False,
default=None,
- show_default=False,
type=float,
help="Enable a global timeout to shut down the server after specified number of minutes of no connection",
)
@click.option(
"--session-ttl",
default=None,
- show_default=False,
type=int,
help="Seconds to wait before closing a session on websocket disconnect. If None is provided, sessions are not automatically closed.",
)
@@ -626,14 +608,12 @@ new_help_msg = "\n".join(
"-p",
"--port",
default=None,
- show_default=True,
type=int,
help="Port to attach to.",
)
@click.option(
"--host",
default="127.0.0.1",
- show_default=True,
type=str,
help="Host to attach to.",
)
@@ -647,35 +627,30 @@ new_help_msg = "\n".join(
"--headless",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Don't launch a browser.",
)
@click.option(
"--token/--no-token",
default=True,
- show_default=True,
type=bool,
help=token_message,
)
@click.option(
"--token-password",
default=None,
- show_default=True,
type=str,
help=token_password_message,
)
@click.option(
"--token-password-file",
default=None,
- show_default=True,
type=str,
help="Path to file containing token password, or '-' for stdin. Mutually exclusive with --token-password.",
)
@click.option(
"--base-url",
default="",
- show_default=True,
type=str,
help="Base URL for the server. Should start with a /.",
callback=validators.base_url,
@@ -684,7 +659,6 @@ new_help_msg = "\n".join(
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=sandbox_message,
)
@@ -692,7 +666,6 @@ new_help_msg = "\n".join(
"--skew-protection/--no-skew-protection",
is_flag=True,
default=True,
- show_default=True,
type=bool,
help="Enable skew protection middleware to prevent version mismatch issues.",
)
@@ -700,7 +673,6 @@ new_help_msg = "\n".join(
"--timeout",
required=False,
default=None,
- show_default=False,
type=float,
help="Enable a global timeout to shut down the server after specified number of minutes of no connection",
)
@@ -904,14 +876,12 @@ Example:
"-p",
"--port",
default=None,
- show_default=True,
type=int,
help="Port to attach to.",
)
@click.option(
"--host",
default="127.0.0.1",
- show_default=True,
type=str,
help="Host to attach to.",
)
@@ -925,28 +895,24 @@ Example:
"--headless",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Don't launch a browser.",
)
@click.option(
"--token/--no-token",
default=False,
- show_default=True,
type=bool,
help=token_message,
)
@click.option(
"--token-password",
default=None,
- show_default=True,
type=str,
help=token_password_message,
)
@click.option(
"--token-password-file",
default=None,
- show_default=True,
type=str,
help="Path to file containing token password, or '-' for stdin. Mutually exclusive with --token-password.",
)
@@ -954,14 +920,12 @@ Example:
"--include-code",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Include notebook code in the app.",
)
@click.option(
"--session-ttl",
default=120,
- show_default=True,
type=int,
help=("Seconds to wait before closing a session on websocket disconnect."),
)
@@ -969,7 +933,6 @@ Example:
"--watch",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help=(
"Watch the file for changes and reload the app. "
@@ -981,14 +944,12 @@ Example:
"--skew-protection/--no-skew-protection",
is_flag=True,
default=True,
- show_default=True,
type=bool,
help="Enable skew protection middleware to prevent version mismatch issues.",
)
@click.option(
"--base-url",
default="",
- show_default=True,
type=str,
help="Base URL for the server. Should start with a /.",
callback=validators.base_url,
@@ -1003,7 +964,6 @@ Example:
"--redirect-console-to-browser",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Redirect console logs to the browser console.",
)
@@ -1011,7 +971,6 @@ Example:
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=sandbox_message,
)
@@ -1019,7 +978,6 @@ Example:
"--check/--no-check",
is_flag=True,
default=True,
- show_default=False,
type=bool,
help=check_message,
)
@@ -1027,7 +985,6 @@ Example:
"--trusted/--untrusted",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help="Run notebooks hosted remotely on the host machine; if --untrusted, runs marimo in a Docker container.",
)
@@ -1240,14 +1197,12 @@ Recommended sequence:
"-p",
"--port",
default=None,
- show_default=True,
type=int,
help="Port to attach to.",
)
@click.option(
"--host",
default="127.0.0.1",
- show_default=True,
type=str,
help="Host to attach to.",
)
@@ -1261,28 +1216,24 @@ Recommended sequence:
"--headless",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Don't launch a browser.",
)
@click.option(
"--token/--no-token",
default=True,
- show_default=True,
type=bool,
help=token_message,
)
@click.option(
"--token-password",
default=None,
- show_default=True,
type=str,
help=token_password_message,
)
@click.option(
"--token-password-file",
default=None,
- show_default=True,
type=str,
help="Path to file containing token password, or '-' for stdin. Mutually exclusive with --token-password.",
)
@@ -1290,7 +1241,6 @@ Recommended sequence:
"--skew-protection/--no-skew-protection",
is_flag=True,
default=True,
- show_default=True,
type=bool,
help="Enable skew protection middleware to prevent version mismatch issues.",
)
@@ -1395,7 +1345,6 @@ def shell_completion() -> None:
"--fix",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Whether to in place update files.",
)
@@ -1403,7 +1352,6 @@ def shell_completion() -> None:
"--strict",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Whether warnings return a non-zero exit code.",
)
@@ -1412,7 +1360,6 @@ def shell_completion() -> None:
"--verbose/--quiet",
is_flag=True,
default=True,
- show_default=True,
type=bool,
help="Whether to print detailed messages.",
)
@@ -1420,7 +1367,6 @@ def shell_completion() -> None:
"--unsafe-fixes",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Enable fixes that may change code behavior (e.g., removing empty cells).",
)
@@ -1428,7 +1374,6 @@ def shell_completion() -> None:
"--ignore-scripts",
is_flag=True,
default=False,
- show_default=True,
type=bool,
help="Ignore files that are not recognizable as marimo notebooks.",
)
@@ -1436,7 +1381,6 @@ def shell_completion() -> None:
"--format",
"formatter",
default="full",
- show_default=True,
type=click.Choice(["full", "json"], case_sensitive=False),
help="Output format for diagnostics.",
)
diff --git a/marimo/_cli/export/commands.py b/marimo/_cli/export/commands.py
index c2bd94a30f..ce61d55a7f 100644
--- a/marimo/_cli/export/commands.py
+++ b/marimo/_cli/export/commands.py
@@ -158,14 +158,12 @@ Optionally pass CLI args to the notebook:
@click.option(
"--include-code/--no-include-code",
default=True,
- show_default=True,
type=bool,
help="Include notebook code in the exported HTML file.",
)
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
type=bool,
help=_watch_message,
)
@@ -183,7 +181,6 @@ Optionally pass CLI args to the notebook:
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@@ -258,7 +255,6 @@ Watch for changes and regenerate the script on modification:
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
type=bool,
help=_watch_message,
)
@@ -276,7 +272,6 @@ Watch for changes and regenerate the script on modification:
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@@ -337,7 +332,6 @@ Watch for changes and regenerate the script on modification:
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
type=bool,
help=_watch_message,
)
@@ -355,7 +349,6 @@ Watch for changes and regenerate the script on modification:
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@@ -420,12 +413,10 @@ Requires nbformat to be installed.
type=click.Choice(["top-down", "topological"]),
default="topological",
help="Sort cells top-down or in topological order.",
- show_default=True,
)
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
type=bool,
help=_watch_message,
)
@@ -442,7 +433,6 @@ Requires nbformat to be installed.
@click.option(
"--include-outputs/--no-include-outputs",
default=False,
- show_default=True,
type=bool,
help="Run the notebook and include outputs in the exported ipynb file.",
)
@@ -450,7 +440,6 @@ Requires nbformat to be installed.
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@@ -536,14 +525,12 @@ Requires nbformat and nbconvert to be installed.
@click.option(
"--include-outputs/--no-include-outputs",
default=True,
- show_default=True,
type=bool,
help="Run the notebook and include outputs in the exported PDF file.",
)
@click.option(
"--webpdf/--no-webpdf",
default=True,
- show_default=True,
type=bool,
help=(
"Use nbconvert's WebPDF exporter (Chromium). If disabled, marimo will "
@@ -553,7 +540,6 @@ Requires nbformat and nbconvert to be installed.
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
type=bool,
help=_watch_message,
)
@@ -568,7 +554,6 @@ Requires nbformat and nbconvert to be installed.
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@@ -716,19 +701,16 @@ and cannot be opened directly from the file system (e.g. file://).
type=click.Choice(["edit", "run"]),
default="run",
help="Whether the notebook code should be editable or readonly.",
- show_default=True,
required=True,
)
@click.option(
"--watch/--no-watch",
default=False,
- show_default=True,
help=("Whether to watch the original file and export upon change"),
)
@click.option(
"--show-code/--no-show-code",
default=False,
- show_default=True,
help=(
"Whether to show code by default in the exported HTML file; "
"only relevant for run mode."
@@ -737,7 +719,6 @@ and cannot be opened directly from the file system (e.g. file://).
@click.option(
"--include-cloudflare/--no-include-cloudflare",
default=False,
- show_default=True,
help=(
"Whether to include Cloudflare Worker configuration files"
" (index.js and wrangler.jsonc) for easy deployment."
@@ -747,7 +728,6 @@ and cannot be opened directly from the file system (e.g. file://).
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
diff --git a/marimo/_cli/export/thumbnail.py b/marimo/_cli/export/thumbnail.py
index a1bf7c25b7..b39c3ad75a 100644
--- a/marimo/_cli/export/thumbnail.py
+++ b/marimo/_cli/export/thumbnail.py
@@ -428,21 +428,18 @@ async def _generate_thumbnails(
"--width",
type=int,
default=1200,
- show_default=True,
help="Viewport width for the screenshot.",
)
@click.option(
"--height",
type=int,
default=630,
- show_default=True,
help="Viewport height for the screenshot.",
)
@click.option(
"--scale",
type=click.IntRange(min=1, max=4),
default=2,
- show_default=True,
help=(
"Device scale factor for screenshots. Output resolution will be "
"`width*scale` x `height*scale`."
@@ -452,7 +449,6 @@ async def _generate_thumbnails(
"--timeout-ms",
type=int,
default=1500,
- show_default=True,
help="Additional time to wait after page load before screenshot.",
)
@click.option(
@@ -467,19 +463,16 @@ async def _generate_thumbnails(
@click.option(
"--overwrite/--no-overwrite",
default=False,
- show_default=True,
help="Overwrite existing thumbnails.",
)
@click.option(
"--include-code/--no-include-code",
default=False,
- show_default=True,
help="Whether to include code in the rendered HTML before screenshot.",
)
@click.option(
"--execute/--no-execute",
default=False,
- show_default=True,
help=(
"Execute notebooks and include their outputs in thumbnails. "
"In --no-execute mode (default), thumbnails are generated from notebook "
@@ -490,14 +483,12 @@ async def _generate_thumbnails(
"--sandbox/--no-sandbox",
is_flag=True,
default=None,
- show_default=False,
type=bool,
help=_sandbox_message,
)
@click.option(
"--continue-on-error/--fail-fast",
default=True,
- show_default=True,
help="Continue processing other notebooks if one notebook fails.",
)
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index 6c18853eda..d2353e1d43 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -777,18 +777,15 @@ def merge_config(
# Patches for backward compatibility
if "runtime" in merged:
if (
- merged["runtime"].get("auto_reload")
- is False # type:ignore[comparison-overlap]
+ merged["runtime"].get("auto_reload") is False # type:ignore[comparison-overlap]
):
merged["runtime"]["auto_reload"] = "off"
elif (
- merged["runtime"].get("auto_reload")
- is True # type:ignore[comparison-overlap]
+ merged["runtime"].get("auto_reload") is True # type:ignore[comparison-overlap]
):
merged["runtime"]["auto_reload"] = "lazy"
elif (
- merged["runtime"].get("auto_reload")
- == "detect" # type:ignore[comparison-overlap]
+ merged["runtime"].get("auto_reload") == "detect" # type:ignore[comparison-overlap]
):
merged["runtime"]["auto_reload"] = "lazy"
diff --git a/tests/_server/test_sessions.py b/tests/_server/test_sessions.py
index 0f6389039a..d0fe8c9d53 100644
--- a/tests/_server/test_sessions.py
+++ b/tests/_server/test_sessions.py
@@ -1149,9 +1149,7 @@ async def test_caching_extension_respects_mode_and_config() -> None:
session_run_enabled = create_session(
SessionMode.RUN, True, serve_cached_sessions_in_apps=True
)
- caching_extension_run_enabled = find_caching_extension(
- session_run_enabled
- )
+ caching_extension_run_enabled = find_caching_extension(session_run_enabled)
assert caching_extension_run_enabled.enabled is True
assert caching_extension_run_enabled.mode is CacheMode.READ