Repository navigation
Conversation
_get_default_string is a copy of Click's formatting with the cases Click
special-cases for Typer. The empty string branch was not carried over, so
Option("", show_default=True) printed no default at all and an option whose
default is deliberately empty looked like an option without one.
Restore the branch so the help output matches Click, and cover it with a
test.
Author
|
Closing this to avoid leaving a stale pull request open. The change itself is small and the branch stays in my fork, so it can be revived if maintainers want it later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
typer.core._get_default_stringis a copy of Click's default-string formatting with the parts Click special-cases for Typer. The empty string case is missing, so an option whose default is deliberately""prints no default at all:Click 8 renders
Name to greet [default: ""], Typer rendersName to greet. An empty default is indistinguishable from "this option has no default to show", which is exactly the case a help string usually needs to spell out — the reader cannot tell whether--namewill be empty or absent.How
Add the branch Click has, before the
Nonecheck:Both the Rich help formatter (
rich_utils._get_parameter_help) and the plain Click one read this helper, so the two stay consistent.Tests
tests/test_rich_utils.py::test_rich_utils_show_default_empty_stringrenders the command above and asserts[default: ""]appears in the help output. It fails on the current implementation and passes with the change; the rest of the file still passes (13 passed).Prepared with the help of an AI assistant.