Open kavinvin opened 2 years ago
Hi @kavinvin,
Since making Tap, we've been hoping to find a way to separate the Namespace
and ArgumentParser
without making typing extremely unpleasant. We couldn't figure out a way to do it. This seems like a totally sensible proposal. We have to think more about this one, but we'll add it to our options in the design doc and update you with our thoughts.
Thanks again, Kyle and Jesse
Currently, parser class and the namespace object are the same type and object.
There're disadvantages doing this:
SimpleArgumentParser().name
will passmypy
checks, but will definitely throw error since argument is not there yet. Meanwhile, inargs = SimpleArgumentParser().parse_args()
,args
will still have irrelevant types information about the parser.Instead, we can have something like:
This is an improvement because:
SimpleArgument
is just a built-indataclass
which can be instantiated normally, getting free hash and equal, free structural pattern matching, and can be tested like normal data.An example of subparser: