From e88e698d6d57713d404bdb220ed76f96f663ddd5 Mon Sep 17 00:00:00 2001 From: timonrieger Date: Sun, 18 Jan 2026 21:17:33 +0100 Subject: [PATCH] fix: show default values for single boolean flags with default=False Previously, single boolean flags (without secondary --no-* options) with default=False would not display their default value in help text, even when show_default=True was set. This made it inconsistent with dual-flag options and other parameter types. Removed the special case in _get_default_string() that hid defaults for single boolean flags with falsy default values. Now all boolean flags consistently show their default values in help text. Example: Before: --dry-run Simulate uploads without actually uploading After: --dry-run Simulate uploads without actually uploading [default: False] Fixes inconsistency where show_default=True had no effect for single boolean flags with default=False. --- typer/core.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/typer/core.py b/typer/core.py index d0d888ccf0..a9836a84ba 100644 --- a/typer/core.py +++ b/typer/core.py @@ -125,13 +125,6 @@ def _get_default_string( else: default_string = _split_opt(obj.secondary_opts[0])[1] # Typer override end - elif ( - isinstance(obj, TyperOption) - and obj.is_bool_flag - and not obj.secondary_opts - and not default_value - ): - default_string = "" else: default_string = str(default_value) return default_string