Closed AlejandroAMarin closed 4 years ago
Hi @ByRellex , I am afraid that the TaurusApplication
cmd_line_parser
API is not adapted to be used with a regular argparse.ArgumentParser
(it works with None
or with a parser from the deprecated taurus.core.util.argparse
module).
Therefore in order to avoid the deprecation warning, I see 2 possibilities:
argparse
in the standard way (i.e. without passing the parser to the TaurusApplication
and explicitly calling parser.parse_args() to retrieve the args
). In this case, your example would be more or less as follows:
parser = argparse.ArgumentParser(
usage="%(prog)s [options]",
description="description"
)
app = TaurusApplication(
cmd_line_parser=None,
app_name="sequencer",
app_version=sardana.Release.version
)
args = parser.parse_args()
Apart, I see a couple of improvements that we could do in Taurus to avoid issues like this one in the future:
TaurusApplication
should raise a TypeError
if cmd_line_parser
is neither None
or a parser returned by taurus.core.util.argparse.get_taurus_parser()
(#1065).
Changed the usage of
taurus.core.util.argparse
since there was a deprecated warning that recommended using argparse of click. I used argparse, but taurus keeps using the old argparse and raises errors when using the new. Error:The changes on the code are these: Old working code:
New code that raises error:
I'm asking for advise on how to use argparse in this situation.
Thanks.