Smarter prediction loop and no- -> no_ in console args (#8151)

* Smarter prediction loop and no- -> no_ in console args

* Fix test
This commit is contained in:
Sylvain Gugger
2020-10-29 10:56:25 -04:00
committed by GitHub
parent b0f1c0ee30
commit acf56408d8
5 changed files with 22 additions and 14 deletions

View File

@@ -66,7 +66,7 @@ class HfArgumentParser(ArgumentParser):
if field.type is bool or (field.default is not None and field.default is not dataclasses.MISSING):
kwargs["action"] = "store_false" if field.default is True else "store_true"
if field.default is True:
field_name = f"--no-{field.name}"
field_name = f"--no_{field.name}"
kwargs["dest"] = field.name
elif hasattr(field.type, "__origin__") and issubclass(field.type.__origin__, List):
kwargs["nargs"] = "+"