Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Partially revert Clean up argparse hacks
  • Loading branch information
cdce8p committed Oct 16, 2025
commit cdcb45d808c3988f2919c557c5ca0f8cc9ec8170
8 changes: 5 additions & 3 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated

__all__ = [
Expand Down Expand Up @@ -36,7 +36,9 @@ ONE_OR_MORE: Final = "+"
OPTIONAL: Final = "?"
PARSER: Final = "A..."
REMAINDER: Final = "..."
SUPPRESS: Final = "==SUPPRESS=="
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
ZERO_OR_MORE: Final = "*"
_UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented

Expand Down Expand Up @@ -79,7 +81,7 @@ class _ActionsContainer:
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
# but using this would make it hard to annotate callers that don't use a
# literal argument and for subclasses to override this method.
nargs: int | str | None = None,
nargs: int | str | _SUPPRESS_T | None = None,
const: Any = ...,
default: Any = ...,
type: _ActionType = ...,
Expand Down