@@ -62,6 +62,15 @@ _T = TypeVar("_T")
62
62
_ActionT = TypeVar ("_ActionT" , bound = Action )
63
63
_ArgumentParserT = TypeVar ("_ArgumentParserT" , bound = ArgumentParser )
64
64
_N = TypeVar ("_N" )
65
+ # more precisely, Literal["store", "store_const", "store_true",
66
+ # "store_false", "append", "append_const", "count", "help", "version",
67
+ # "extend"], but using this would make it hard to annotate callers
68
+ # that don't use a literal argument
69
+ _ActionStr = str
70
+ # more precisely, Literal["?", "*", "+", "...", "A...",
71
+ # "==SUPPRESS=="], but using this would make it hard to annotate
72
+ # callers that don't use a literal argument
73
+ _NArgsStr = str
65
74
66
75
ONE_OR_MORE : Literal ["+" ]
67
76
OPTIONAL : Literal ["?" ]
@@ -106,11 +115,8 @@ class _ActionsContainer:
106
115
def add_argument (
107
116
self ,
108
117
* name_or_flags : str ,
109
- action : Literal [
110
- "store" , "store_const" , "store_true" , "store_false" , "append" , "append_const" , "count" , "help" , "version" , "extend"
111
- ]
112
- | type [Action ] = ...,
113
- nargs : int | Literal ["?" , "*" , "+" , "..." , "A..." , "==SUPPRESS==" ] | _SUPPRESS_T = ...,
118
+ action : _ActionStr | type [Action ] = ...,
119
+ nargs : int | _NArgsStr | _SUPPRESS_T = ...,
114
120
const : Any = ...,
115
121
default : Any = ...,
116
122
type : Callable [[str ], _T ] | FileType = ...,
0 commit comments