Skip to content

Commit

Permalink
🐛 Fix default value handling in parameter help extraction when rich i…
Browse files Browse the repository at this point in the history
…s installed

Fixes #465

Improves consitency with typer/core.py TyperArgument.get_help_record, which does not print the default value if it is None.
  • Loading branch information
mattmess1221 committed Jan 14, 2025
1 parent f110845 commit b2234d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions typer/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ def _get_parameter_help(
# Default value
# This uses Typer's specific param._get_default_string
if isinstance(param, (TyperOption, TyperArgument)):
if param.show_default:
show_default_is_str = isinstance(param.show_default, str)
default_value = param._extract_default_help_str(ctx=ctx)
default_value = param._extract_default_help_str(ctx=ctx)
show_default_is_str = isinstance(param.show_default, str)
if show_default_is_str or (default_value is not None and (param.show_default or ctx.show_default)):
default_str = param._get_default_string(
ctx=ctx,
show_default_is_str=show_default_is_str,
Expand Down

0 comments on commit b2234d9

Please sign in to comment.