(original) (raw)
Hello,
argparse does prefix matching as long as there are no conflicts. For example:argparser = argparse.ArgumentParser()
argparser.add\_argument('--sync-foo', action='store\_true')
argparser.add\_argument('--sync-foo', action='store\_true')
args = argparser.parse_args()
If there's another argument registered, say "--sync-bar" the above will fail due to a conflict.
Now comes the nasty part. When using "parse_known_args" instead of "parse_args", the above happens too - --sync is recognized for --sync-foo and captured by the parser. But this is wrong! The whole idea of parse_known_args is to parse the known args, leaving unknowns alone. This prefix matching harms more than it helps here because maybe the program we're actually acting as a front-end for (and hence using parse_known_args) knows about --sync and wants to get it.
Eli