Bug: NoSuchOption.format_message() returns tuple repr instead of plain string #1840
Unanswered
foomunleong
asked this question in
Questions
Replies: 1 comment 1 reply
-
|
Thanks for the report! While we continue refactoring on top of the vendored Click, things might still change a bit, especially these error messages. They might not stay exactly the same. That said, it does look like this particular comma is a bug and can be removed. Feel free to PR this! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Example Code
Description
Bug
NoSuchOption.format_message()intyper/_click/exceptions.pyproduces a tuplerepr in its output instead of a plain string when
possibilitiesis non-empty.Current output:
Error: No such option: --fooo ('(Possible options: --foo)',)Expected output:
Error: No such option: --fooo (Possible options: --foo)Root cause
In
typer/_click/exceptions.py, thesuggestvariable is assigned a 1-elementtuple due to a trailing comma:
When
suggest(a tuple) is interpolated into the f-string, Python renders it as('(Possible options: ...)',)rather than(Possible options: ...).Proposed fix
Remove the trailing comma so
suggestis a plain string:This matches the behaviour of the upstream Click library's own
NoSuchOption.Operating System
macOS
Operating System Details
No response
Project Version
master
Python Version
No response
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions