@@ -2,7 +2,7 @@ import sys
2
2
from _typeshed import SupportsWrite , sentinel
3
3
from collections .abc import Callable , Generator , Iterable , Sequence
4
4
from re import Pattern
5
- from typing import IO , Any , ClassVar , Final , Generic , NoReturn , Protocol , TypeVar , overload
5
+ from typing import IO , Any , ClassVar , Final , Generic , NewType , NoReturn , Protocol , TypeVar , overload
6
6
from typing_extensions import Self , TypeAlias , deprecated
7
7
8
8
__all__ = [
@@ -36,7 +36,9 @@ ONE_OR_MORE: Final = "+"
36
36
OPTIONAL : Final = "?"
37
37
PARSER : Final = "A..."
38
38
REMAINDER : Final = "..."
39
- SUPPRESS : Final = "==SUPPRESS=="
39
+ _SUPPRESS_T = NewType ("_SUPPRESS_T" , str )
40
+ SUPPRESS : _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
41
+ # the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
40
42
ZERO_OR_MORE : Final = "*"
41
43
_UNRECOGNIZED_ARGS_ATTR : Final = "_unrecognized_args" # undocumented
42
44
@@ -79,7 +81,7 @@ class _ActionsContainer:
79
81
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
80
82
# but using this would make it hard to annotate callers that don't use a
81
83
# literal argument and for subclasses to override this method.
82
- nargs : int | str | None = None ,
84
+ nargs : int | str | _SUPPRESS_T | None = None ,
83
85
const : Any = ...,
84
86
default : Any = ...,
85
87
type : _ActionType = ...,
0 commit comments