Using Annotated on Lists leads to crash #861
Unanswered
secretrobotron
asked this question in
Questions
Replies: 2 comments 1 reply
-
Hi! You have to declare the default value slightly differently with
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I think I have a similar situation here. The following code runs fine when using typer 0.16 and pinning click to <8.2 but fails with def get_hashed_default() -> bool:
config = Config.from_cmdargs() # This needs typer initialized to work. So we need the default to be a callable.
return config.hash_subject_ids
@app.command
def foo(hash_subject_ids: Annotated[bool, typer.Option(
help='Whether to hash the subject IDs. Overrides the `hash_subject_ids` setting.',
default_factory=get_hashed_default,
show_default=False,
),
]
) |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
First Check
Commit to Help
Example Code
Description
While trying to work around this problem, I ran into a new one. I have (I think) used
Annotated
correctly, but when I run the example code, I get this error:If I comment out
test2
, it works fine.The traceback suggests the problem might be within Click, but I'm unsure:
Operating System
macOS
Operating System Details
No response
Typer Version
0.9.4
Python Version
3.11.7
Additional Context
Similar issues:
Beta Was this translation helpful? Give feedback.
All reactions