Content-Length: 303785 | pFad | http://github.com/python/mypy/commit/59cbace4d5865f28b3bdafa4b8c3a470e409edb6

37 Partially revert Clean up argparse hacks · python/mypy@59cbace · GitHub
Skip to content

Commit 59cbace

Browse files
cdce8pmypybot
authored and
mypybot
committed
Partially revert Clean up argparse hacks
1 parent aeda66d commit 59cbace

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mypy/typeshed/stdlib/argparse.pyi

Lines 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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/mypy/commit/59cbace4d5865f28b3bdafa4b8c3a470e409edb6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy