Repository navigation
Add to_argv utility function that constructs an argv list. - #187
carlosgmartin wants to merge 1 commit into
Conversation
|
Hi @carlosgmartin, Thank you for this PR! Our key concern is that it is often challenging to automatically reconstruct the argument list from an object instance. For example, from tap import Tap
class Args(Tap):
number: int
def configure(self) -> None:
self.add_argument("--number", type=lambda value: int(value) + 1)The original argument is parsed as follows: args = Args().parse_args(["--number", "1"])
assert args.number == 2
argv = to_argv(args)
assert argv == ["--number", "2"]Reparsing those arguments changes the value again: reparsed = Args().parse_args(argv)
assert reparsed.number == 3Therefore: assert args.as_dict() != reparsed.as_dict()
More generally, it is challenging to support custom actions, subparsers, complex nargs, duplicate destinations, and other configurations whose final values do not uniquely determine a valid We will leave this issue open for a few weeks for potential further discussion. Thanks again and we wish you happy Tapping, |
Fixes #186.