@@ -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
5+ from typing import IO , Any , ClassVar , Final , Generic , NewType , NoReturn , Protocol , TypeVar , overload
66from typing_extensions import Self , TypeAlias , deprecated
77
88__all__ = [
@@ -38,7 +38,9 @@ ONE_OR_MORE: Final = "+"
3838OPTIONAL : Final = "?"
3939PARSER : Final = "A..."
4040REMAINDER : 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
4244ZERO_OR_MORE : Final = "*"
4345_UNRECOGNIZED_ARGS_ATTR : Final = "_unrecognized_args" # undocumented
4446
@@ -81,7 +83,7 @@ class _ActionsContainer:
8183 # more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8284 # but using this would make it hard to annotate callers that don't use a
8385 # literal argument and for subclasses to override this method.
84- nargs : int | str | None = None ,
86+ nargs : int | str | _SUPPRESS_T | None = None ,
8587 const : Any = ...,
8688 default : Any = ...,
8789 type : _ActionType = ...,
0 commit comments