Weird behavior when wrongly combining Annotated
with List
#713
Unanswered
The-Compiler
asked this question in
Questions
Replies: 1 comment 1 reply
-
Actually, I would say the usage is wrong here. Your code would work just fine if you had done the reverse: def test(arg: Annotated[List[str], typer.Argument(help="test")]): # <- yay!
print("test") |
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
-
First Check
Commit to Help
Example Code
Description
On Python 3.8, this results in:
from here:
typer/typer/main.py
Lines 834 to 836 in 4c6098f
On newer Python versions, this works, but the
typer.Argument
silently gets dropped. See--help
:as opposed to using
Annotated[List[str], typer.Argument(help="test")]
correctly:The fact that Python 3.9+ fails silently is due to
typing.get_type_hints()
by default stripping metadata there. Thus, when it's called here:typer/typer/utils.py
Line 110 in 4c6098f
the
Annotated
part gets dropped here:typer/typer/utils.py
Lines 164 to 166 in 4c6098f
Operating System
Linux
Operating System Details
No response
Typer Version
0.9.0
Python Version
3.8.18, 3.9.18, 3.11.6
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions