You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to add sub-commands to my CLI using functools.partial but typing.get_type_hints doesn't support it. I found that it's sufficient to change the call to this function in utils.py:get_params_from_function (with functools import):
This is the alternative to the monkey patch included in the example code which demonstrates that the desired behaviour works.
It might also be desirable to allow typer.run() to accept a functools.partial. Currently there's no default command name and so it fails to determine one automatically because functools.partial doesn't have a __name__ attribute.
I'm happy to contribute a PR but wanted to make sure that it would be accepted first before adding tests and documentation for it, etc.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
Description
I'd like to be able to add sub-commands to my CLI using
functools.partial
buttyping.get_type_hints
doesn't support it. I found that it's sufficient to change the call to this function inutils.py:get_params_from_function
(withfunctools
import):This is the alternative to the monkey patch included in the example code which demonstrates that the desired behaviour works.
It might also be desirable to allow
typer.run()
to accept afunctools.partial
. Currently there's no default command name and so it fails to determine one automatically becausefunctools.partial
doesn't have a__name__
attribute.I'm happy to contribute a PR but wanted to make sure that it would be accepted first before adding tests and documentation for it, etc.
Operating System
Windows
Operating System Details
No response
Typer Version
0.9.0
Python Version
3.11.1
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions