Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/transformers/hf_argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def _parse_dataclass_field(parser: ArgumentParser, field: dataclasses.Field):
" the argument parser only supports one type per argument."
f" Problem encountered in field '{field.name}'."
)
# filter `dict` in Union because argparse does not support it
if dict in field.type.__args__:
field.type = Union[tuple(arg for arg in field.type.__args__ if arg is not dict)]
if type(None) not in field.type.__args__:
# filter `str` in Union
field.type = field.type.__args__[0] if field.type.__args__[1] is str else field.type.__args__[1]
Expand Down