Fix typing annotation in hf_argparser (#30156)

This commit is contained in:
Xu Song 2024-04-10 22:58:56 +08:00 committed by GitHub
parent 0f94e3e152
commit 33bca5419c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -376,7 +376,7 @@ class HfArgumentParser(ArgumentParser):
raise ValueError(f"Some keys are not used by the HfArgumentParser: {sorted(unused_keys)}") raise ValueError(f"Some keys are not used by the HfArgumentParser: {sorted(unused_keys)}")
return tuple(outputs) 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 Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the
dataclass types. dataclass types.
@ -398,7 +398,7 @@ class HfArgumentParser(ArgumentParser):
outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys) outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys)
return tuple(outputs) 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 Alternative helper method that does not use `argparse` at all, instead loading a yaml file and populating the
dataclass types. dataclass types.