Closed baodrate closed 4 months ago
tapify
currently doesn't work when there are positional-only arguments.
For example, try to run your script (instead of just -h
)
$ python script.py --num1 1 --num2 2 --bar "bar"
Traceback (most recent call last):
File "/Users/kdubey/projects/typed-argument-parser/script.py", line 16, in <module>
tapify(foo)
File "/Users/kdubey/projects/typed-argument-parser/tap/tapify.py", line 335, in tapify
return class_or_function(**command_line_args_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: foo() got some positional-only arguments passed as keyword arguments: 'num1, num2'
I'll fix this bug
Hi @baod-rate,
I didn't know about this feature. Thank you for raising this issue. I agree that this is a bug and that it should be addressed. @kddubey thank you very much for offering to fix it!
--Jesse
Thank you @kddubey for the fix!
--JK
Currently, the
tapify
interface creates "options"/flags (--
prefixed, position-agnostic arguments) for each parameter in the function signature. e.g.:produces:
Since parameters that follow
/
are positional-only,tapify
should omit the--
prefix when it callsadd_argument(...)
, so thatargparse
creates a positional argument.