@@ -2,7 +2,7 @@ import sys
22from _typeshed import SupportsWrite , sentinel
33from collections .abc import Callable , Generator , Iterable , Sequence
44from re import Pattern
5- from typing import IO , Any , ClassVar , Final , Generic , NoReturn , Protocol , TypeVar , overload , type_check_only
5+ from typing import IO , Any , ClassVar , Final , Generic , NewType , NoReturn , Protocol , TypeVar , overload , type_check_only
66from typing_extensions import Self , TypeAlias , deprecated
77
88__all__ = [
@@ -36,7 +36,9 @@ ONE_OR_MORE: Final = "+"
3636OPTIONAL : Final = "?"
3737PARSER : Final = "A..."
3838REMAINDER : 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
4042ZERO_OR_MORE : Final = "*"
4143_UNRECOGNIZED_ARGS_ATTR : Final = "_unrecognized_args" # undocumented
4244
@@ -79,7 +81,7 @@ class _ActionsContainer:
7981 # more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8082 # but using this would make it hard to annotate callers that don't use a
8183 # literal argument and for subclasses to override this method.
82- nargs : int | str | None = None ,
84+ nargs : int | str | _SUPPRESS_T | None = None ,
8385 const : Any = ...,
8486 default : Any = ...,
8587 type : _ActionType = ...,
0 commit comments