Support Unpack
aka PEP 692 annotations
#665
Replies: 4 comments 6 replies
-
This would solve a lot of argument re-use requirements in #153 |
Beta Was this translation helpful? Give feedback.
-
Also running into this, and would love to have it. Would be really nice to be able to define a base set of cli options to include on all methods. There's a lot going on in #153 that would be greatly simplified with PEP 692 support. |
Beta Was this translation helpful? Give feedback.
-
Strong yes from us! We're using typer for github.com/robusta-dev/holmesgpt/ and github.com/robusta-dev/krr/ and this would solve some annoying problems. |
Beta Was this translation helpful? Give feedback.
-
Giving this more thought, I believe that TypedDict doesn't allow something like this:
However Annotated should work fine, which is an acceptable compromise I think |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
Above is a fairly simple example of how
Unpack
might be used with typer. There are many reasons why a user might want to do this, as outlined in the PEP. My immediate use case for this is to re-use an argument definition I use elsewhere, so I don't have to duplicate the function's type signature and risk the duplicated copies getting out of sync.Typer would be able to support this by introspecting the
TypedDict
using__optional_keys__
etc.Operating System
Linux, macOS
Operating System Details
Monterey (12.6)
Typer Version
0.9.0
Python Version
3.11.5
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions