Unverified Commit 7af55d3a authored by David del Río Medina's avatar David del Río Medina Committed by GitHub
Browse files

Replace assertion with ValueError exception (#14098)

parent f00bceab
...@@ -133,9 +133,8 @@ class HfArgumentParser(ArgumentParser): ...@@ -133,9 +133,8 @@ class HfArgumentParser(ArgumentParser):
): ):
kwargs["nargs"] = "+" kwargs["nargs"] = "+"
kwargs["type"] = field.type.__args__[0] kwargs["type"] = field.type.__args__[0]
assert all( if not all(x == kwargs["type"] for x in field.type.__args__):
x == kwargs["type"] for x in field.type.__args__ raise ValueError(f"{field.name} cannot be a List of mixed types")
), f"{field.name} cannot be a List of mixed types"
if field.default_factory is not dataclasses.MISSING: if field.default_factory is not dataclasses.MISSING:
kwargs["default"] = field.default_factory() kwargs["default"] = field.default_factory()
elif field.default is dataclasses.MISSING: elif field.default is dataclasses.MISSING:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment