@@ -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__ = [
@@ -38,7 +38,9 @@ ONE_OR_MORE: Final = "+"
38
38
OPTIONAL : Final = "?"
39
39
PARSER : Final = "A..."
40
40
REMAINDER : Final = "..."
41
- SUPPRESS : Final = "==SUPPRESS=="
41
+ _SUPPRESS_T = NewType ("_SUPPRESS_T" , str )
42
+ SUPPRESS : _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
43
+ # the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
42
44
ZERO_OR_MORE : Final = "*"
43
45
_UNRECOGNIZED_ARGS_ATTR : Final = "_unrecognized_args" # undocumented
44
46
@@ -81,7 +83,7 @@ class _ActionsContainer:
81
83
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
82
84
# but using this would make it hard to annotate callers that don't use a
83
85
# literal argument and for subclasses to override this method.
84
- nargs : int | str | None = None ,
86
+ nargs : int | str | _SUPPRESS_T | None = None ,
85
87
const : Any = ...,
86
88
default : Any = ...,
87
89
type : _ActionType = ...,
0 commit comments