From 6d785108d0a41b9658457519aae0550dc1accee7 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 3 Nov 2023 07:51:15 -0500 Subject: [PATCH 1/3] enable typing annotion override --- src/transformers/hf_argparser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transformers/hf_argparser.py b/src/transformers/hf_argparser.py index 34570588744a..8681304f898c 100644 --- a/src/transformers/hf_argparser.py +++ b/src/transformers/hf_argparser.py @@ -21,13 +21,15 @@ from enum import Enum from inspect import isclass from pathlib import Path -from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optional, Tuple, Union, get_type_hints +from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optional, Tuple, Union, get_type_hints, TypeVar import yaml DataClass = NewType("DataClass", Any) DataClassType = NewType("DataClassType", Any) +T = TypeVar("T") + # From https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse @@ -269,7 +271,7 @@ def parse_args_into_dataclasses( look_for_args_file=True, args_filename=None, args_file_flag=None, - ) -> Tuple[DataClass, ...]: + ) -> Tuple[T, ...]: """ Parse command-line args into instances of the specified dataclass types. From 301f5b550dd92daf44c0670425f9e067d4b3b029 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 3 Nov 2023 16:02:49 -0500 Subject: [PATCH 2/3] black --- src/transformers/hf_argparser.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/transformers/hf_argparser.py b/src/transformers/hf_argparser.py index 8681304f898c..6e0a256624aa 100644 --- a/src/transformers/hf_argparser.py +++ b/src/transformers/hf_argparser.py @@ -21,7 +21,20 @@ from enum import Enum from inspect import isclass from pathlib import Path -from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optional, Tuple, Union, get_type_hints, TypeVar +from typing import ( + Any, + Callable, + Dict, + Iterable, + List, + Literal, + NewType, + Optional, + Tuple, + Union, + get_type_hints, + TypeVar, +) import yaml @@ -31,7 +44,6 @@ T = TypeVar("T") - # From https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse def string_to_bool(v): if isinstance(v, bool): From b87f0680dc7fe7f5506086f9aad82fbdb942332d Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 3 Nov 2023 21:19:15 +0000 Subject: [PATCH 3/3] quick fix --- src/transformers/hf_argparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/hf_argparser.py b/src/transformers/hf_argparser.py index 6e0a256624aa..20b0996b38b4 100644 --- a/src/transformers/hf_argparser.py +++ b/src/transformers/hf_argparser.py @@ -31,9 +31,9 @@ NewType, Optional, Tuple, + TypeVar, Union, get_type_hints, - TypeVar, ) import yaml