Closed
Description
Feature request
Given a dataclass
from dataclasses import dataclass
@dataclass
class Config:
item_type: str
item_length: int
I would expect HfArgumentParser.parse_args_into_dataclasses
to correctly parse parameters like --item-type
or --item-length
(with a hyphen instead of an underscore). Unfortunately, it doesn't:
from transformers import HfArgumentParser
parser = HfArgumentParser([Config])
parser.parse_args_into_dataclasses(args=["--item-type", "my_type", "--item-length", "23"])
throws an error because it is expecting --item_type
and --item_length
.
Motivation
- Consistency with
argparse
.argparse
converts hyphens into underscores before assignment:If no long option strings were supplied, dest will be derived from the first short option string by stripping the initial - character. Any internal - characters will be converted to _ characters to make sure the string is a valid attribute name.
- It is standard convention to use hyphens in long-option parameters (e.g.,
--file-type
, not--file_type
).
Your contribution
If there is no reason preventing this feature request to be accepted, yes, I could contribute to a PR.
I just want to know if there is a fundamental reason why this is not implemented yet.