Unverified Commit 544fd987 authored by Konstantin Dobler's avatar Konstantin Dobler Committed by GitHub
Browse files

Support modern list type hints in HfArgumentParser (#15951)

* Support modern list type hint in HfArgumentParser

* Fix formatting with black
parent 60b81dfa
......@@ -129,7 +129,8 @@ class HfArgumentParser(ArgumentParser):
# This is the value that will get picked if we do --field_name (without value)
kwargs["const"] = True
elif (
hasattr(field.type, "__origin__") and re.search(r"^typing\.List\[(.*)\]$", str(field.type)) is not None
hasattr(field.type, "__origin__")
and re.search(r"^(typing\.List|list)\[(.*)\]$", str(field.type)) is not None
):
kwargs["nargs"] = "+"
kwargs["type"] = field.type.__args__[0]
......
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