Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d8f636b

Browse filesBrowse files
committed
Partially revert Clean up argparse hacks
1 parent 1dae03c commit d8f636b
Copy full SHA for d8f636b

File tree

Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed

‎mypy/typeshed/stdlib/argparse.pyi

Copy file name to clipboardExpand all lines: mypy/typeshed/stdlib/argparse.pyi
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import SupportsWrite, sentinel
33
from collections.abc import Callable, Generator, Iterable, Sequence
44
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
66
from typing_extensions import Self, TypeAlias, deprecated
77

88
__all__ = [
@@ -38,7 +38,9 @@ ONE_OR_MORE: Final = "+"
3838
OPTIONAL: Final = "?"
3939
PARSER: Final = "A..."
4040
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
4244
ZERO_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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.