Skip to content

Commit

Permalink
Fix typing annotation in hf_argparser (#30156)
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-song authored Apr 10, 2024
1 parent 0f94e3e commit 33bca54
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/hf_argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def parse_dict(self, args: Dict[str, Any], allow_extra_keys: bool = False) -> Tu
raise ValueError(f"Some keys are not used by the HfArgumentParser: {sorted(unused_keys)}")
return tuple(outputs)

def parse_json_file(self, json_file: str, allow_extra_keys: bool = False) -> Tuple[DataClass, ...]:
def parse_json_file(self, json_file: Union[str, Path], allow_extra_keys: bool = False) -> Tuple[DataClass, ...]:
"""
Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the
dataclass types.
Expand All @@ -398,7 +398,7 @@ def parse_json_file(self, json_file: str, allow_extra_keys: bool = False) -> Tup
outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys)
return tuple(outputs)

def parse_yaml_file(self, yaml_file: str, allow_extra_keys: bool = False) -> Tuple[DataClass, ...]:
def parse_yaml_file(self, yaml_file: Union[str, Path], allow_extra_keys: bool = False) -> Tuple[DataClass, ...]:
"""
Alternative helper method that does not use `argparse` at all, instead loading a yaml file and populating the
dataclass types.
Expand Down

0 comments on commit 33bca54

Please sign in to comment.