BUG: Allow string/path lists for multi-value Python API arguments - #97
BUG: Allow string/path lists for multi-value Python API arguments#97axel-grc wants to merge 3 commits into
Conversation
Multi-value (nargs="+") options were only comma-split for non-str types because the neutralization gate skipped str-typed arguments. Passing a list of paths through the Python API, e.g. pct.pctcheckimagequality(reference=["a.nrrd","b.nrrd"]), serialized as a single comma token but was never split, yielding one bogus filename "a.nrrd,b.nrrd". Neutralize the type of every nargs="+" option, including str/path lists, then split comma tokens and re-cast each piece (str cast is a no-op).
SimonRit
left a comment
There was a problem hiding this comment.
I'm mostly unable to read this code. It would be good to add some documentation to required_dests and is there any way of testing this?
|
I created a small test: acoussat@4bbce8d. The test does not pass with the previous version of the code but works using this branch. Should I add this test to this PR, or perhaps even push it to RTK? |
Here is good I believe. Thanks! |
|
Thanks @acoussat ! |
|
https://docs.python.org/3/library/argparse.html#option-value-syntax |
- Collapse the numeric-only neutralization loop and the two split/cast branches in parse_args into a single unified pass for every nargs="+" option, and restore original types in a finally block so the parser stays reusable across calls. - Extract required_dests() shared by build_signature() and build_usage_examples(). - Simplify option-flag selection in parse_kwargs().
Multi-value (nargs="+") options were only comma-split for non-str types
because the neutralization gate skipped str-typed arguments. Passing a
list of paths through the Python API, e.g.
pct.pctcheckimagequality(reference=["a.nrrd","b.nrrd"]), serialized as
a single comma token but was never split, yielding one bogus filename
"a.nrrd,b.nrrd".
Neutralize the type of every nargs="+" option, including str/path lists,
then split comma tokens and re-cast each piece (str cast is a no-op).