1818import sys
1919import types
2020from argparse import ArgumentDefaultsHelpFormatter , ArgumentParser , ArgumentTypeError
21+ from collections .abc import Iterable
2122from copy import copy
2223from enum import Enum
2324from inspect import isclass
2425from pathlib import Path
25- from typing import Any , Callable , Dict , Iterable , List , Literal , NewType , Optional , Tuple , Union , get_type_hints
26+ from typing import Any , Callable , Literal , NewType , Optional , Union , get_type_hints
2627
2728import yaml
2829
@@ -62,7 +63,7 @@ def make_choice_type_function(choices: list) -> Callable[[str], Any]:
6263
6364def HfArg (
6465 * ,
65- aliases : Union [str , List [str ]] = None ,
66+ aliases : Union [str , list [str ]] = None ,
6667 help : str = None ,
6768 default : Any = dataclasses .MISSING ,
6869 default_factory : Callable [[], Any ] = dataclasses .MISSING ,
@@ -254,7 +255,7 @@ def _add_dataclass_arguments(self, dtype: DataClassType):
254255 parser = self
255256
256257 try :
257- type_hints : Dict [str , type ] = get_type_hints (dtype )
258+ type_hints : dict [str , type ] = get_type_hints (dtype )
258259 except NameError :
259260 raise RuntimeError (
260261 f"Type resolution failed for { dtype } . Try declaring the class in global scope or "
@@ -288,7 +289,7 @@ def parse_args_into_dataclasses(
288289 look_for_args_file = True ,
289290 args_filename = None ,
290291 args_file_flag = None ,
291- ) -> Tuple [DataClass , ...]:
292+ ) -> tuple [DataClass , ...]:
292293 """
293294 Parse command-line args into instances of the specified dataclass types.
294295
@@ -367,7 +368,7 @@ def parse_args_into_dataclasses(
367368
368369 return (* outputs ,)
369370
370- def parse_dict (self , args : Dict [str , Any ], allow_extra_keys : bool = False ) -> Tuple [DataClass , ...]:
371+ def parse_dict (self , args : dict [str , Any ], allow_extra_keys : bool = False ) -> tuple [DataClass , ...]:
371372 """
372373 Alternative helper method that does not use `argparse` at all, instead uses a dict and populating the dataclass
373374 types.
@@ -397,7 +398,7 @@ def parse_dict(self, args: Dict[str, Any], allow_extra_keys: bool = False) -> Tu
397398
398399 def parse_json_file (
399400 self , json_file : Union [str , os .PathLike ], allow_extra_keys : bool = False
400- ) -> Tuple [DataClass , ...]:
401+ ) -> tuple [DataClass , ...]:
401402 """
402403 Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the
403404 dataclass types.
@@ -421,7 +422,7 @@ def parse_json_file(
421422
422423 def parse_yaml_file (
423424 self , yaml_file : Union [str , os .PathLike ], allow_extra_keys : bool = False
424- ) -> Tuple [DataClass , ...]:
425+ ) -> tuple [DataClass , ...]:
425426 """
426427 Alternative helper method that does not use `argparse` at all, instead loading a yaml file and populating the
427428 dataclass types.
0 commit comments