Update no_* argument (HfArgumentParser) (#13865)
* update no_* argument Changes the order so that the no_* argument is created after the original argument AND sets the default for this no_* argument to False * import copy * update test * make style * Use kwargs to set default=False * make style
This commit is contained in:
@@ -126,8 +126,10 @@ class HfArgumentParserTest(unittest.TestCase):
|
||||
|
||||
expected = argparse.ArgumentParser()
|
||||
expected.add_argument("--foo", type=string_to_bool, default=False, const=True, nargs="?")
|
||||
expected.add_argument("--no_baz", action="store_false", dest="baz")
|
||||
expected.add_argument("--baz", type=string_to_bool, default=True, const=True, nargs="?")
|
||||
# A boolean no_* argument always has to come after its "default: True" regular counter-part
|
||||
# and its default must be set to False
|
||||
expected.add_argument("--no_baz", action="store_false", default=False, dest="baz")
|
||||
expected.add_argument("--opt", type=string_to_bool, default=None)
|
||||
self.argparsersEqual(parser, expected)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user