mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Use Final for Constant Literals in the stdlib (#12332)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import sentinel
|
||||
from collections.abc import Callable, Generator, Iterable, Sequence
|
||||
from re import Pattern
|
||||
from typing import IO, Any, Generic, Literal, NewType, NoReturn, Protocol, TypeVar, overload
|
||||
from typing import IO, Any, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload
|
||||
from typing_extensions import Self, TypeAlias, deprecated
|
||||
|
||||
__all__ = [
|
||||
@@ -43,14 +43,14 @@ _ActionStr: TypeAlias = str
|
||||
# callers that don't use a literal argument
|
||||
_NArgsStr: TypeAlias = str
|
||||
|
||||
ONE_OR_MORE: Literal["+"]
|
||||
OPTIONAL: Literal["?"]
|
||||
PARSER: Literal["A..."]
|
||||
REMAINDER: Literal["..."]
|
||||
ONE_OR_MORE: Final = "+"
|
||||
OPTIONAL: Final = "?"
|
||||
PARSER: Final = "A..."
|
||||
REMAINDER: Final = "..."
|
||||
_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: Literal["*"]
|
||||
ZERO_OR_MORE: Final = "*"
|
||||
_UNRECOGNIZED_ARGS_ATTR: str # undocumented
|
||||
|
||||
class ArgumentError(Exception):
|
||||
|
||||
Reference in New Issue
Block a user