-
First Check
Commit to Help
Example Codefrom __future__ import annotations
import typer
from typing_extensions import Annotated
def main(
name: str,
lastname: Annotated[str, typer.Option(help="Last name of person to greet.")] = "",
formal: Annotated[bool, typer.Option(help="Say hi formally.")] = False,
):
"""
Say hi to NAME, optionally with a --lastname.
If --formal is used, say hi very formally.
"""
if formal:
print(f"Good day Ms. {name} {lastname}.")
else:
print(f"Hello {name} {lastname}")
if __name__ == "__main__":
typer.run(main) Description
Operating SystemWindows Operating System DetailsNo response Typer Version0.9.0 Python VersionPython 3.11.3 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
I'm running into this same issue. Where does this happen?The issue starts in Because these annotations are stringized, the subsequent calls to How could this be fixed?In Python 3.10 and higher, For Python 3.9 and lower, the process is somewhat involved. The annotations how-to [doc] suggests emulating the behavior of From the how-to:
|
Beta Was this translation helpful? Give feedback.
-
Also running into this issue and going slightly mad trying to figure out what was happening. |
Beta Was this translation helpful? Give feedback.
-
Related PR: #721 |
Beta Was this translation helpful? Give feedback.
-
I just found another bug about |
Beta Was this translation helpful? Give feedback.
Thanks for the report @jfcherng and for the discussion everyone! 🤓
This was indeed (probably) solved by #721, available in Typer 0.9.3, released in the next few hours. 🚀