Open oren-hecht opened 7 months ago
Hi @oren-hecht,
Thank you for raising this issue! Both of your suggestion make sense.
The first change would be to keep all of the information specified by the class variable and then have configure extend/overwrite it. We agree this would help eliminate redundancy.
Additionally, perhaps we could leverage Annotated
to specify shortened arg names. For example, argument_with_really_long_name: Annotated[int, short_name=arg]
.
Thank you again for these ideas! We welcome any contributions.
Best, JK
There is a very common practice in scripts, to allow both "long syntax" and shorter versions of some argument name. [The documentation] (https://github.com/swansonk14/typed-argument-parser?tab=readme-ov-file#adding-special-argument-behavior) suggests using
add_argument
to achieve this:However, In the case where I had defined properties on this argument, the operation will overwrite these
In this case, the default value and the help description will be lost. In my project, we have many such arguments, sometimes defined with more complex properties such as
list[Literal]
types - it is a shame that the second we want to allow a shorter argument name, we lose all the powerfulTap
features that allow defining argument properties. An example from our code:I want to allow shorter names here - and so have to add all the following lines
by the way, the same problem is present if we want to allow the CLI options to be in kebab-case (the linux standard) as opposed to snake_case, as can be seen above (since you cannot define class member names using kebab-case in python).
PROPOSAL
Only overwrite the specific
add_argument
options being used, and take the rest from the class member. Or, possible, make some simpler syntax that allows assigning an alternative argument name