Add an Option argument, to mask its value in case of exceptions #1164
-
First Check
Commit to Help
Example Codefrom typer import Option, Typer
cli = Typer(no_args_is_help=True, add_completion=False)
@cli.command()
def deploy(
env: str = Option(...),
version: str = Option(...),
api_token: str = Option(...) # <--- I'd like ONLY thos value to not be displayed on exception
) -> None:
raise Exception("blah") DescriptionI have a Typer script, that does... well a lot 😆 . In some cases, it handles secrets (passwords, tokens, etc.), and when errors happen in those codepaths, I'd like to hide ONLY those values and not other arguments, as they provide helpful information regarding debugging. Perhaps Operating SystemmacOS Operating System DetailsNo response Typer Version0.15.1 Python Version3.13.2 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Beta Was this translation helpful? Give feedback.
Oh, sorry.. You are right.
Is it suitable for you to use SecretStr from Pydantic?
As I understand, the way you would do it with Click is to set
expose_value=False
and use callback to store it into context: