Use TypeAlias for argparse type aliases (#7664)

This commit is contained in:
Alex Waygood
2022-04-20 15:32:10 +01:00
committed by GitHub
parent 85594df83b
commit c653be73b8

View File

@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Generator, Iterable, Sequence
from typing import IO, Any, Generic, NewType, NoReturn, Pattern, Protocol, TypeVar, overload
from typing_extensions import Literal
from typing_extensions import Literal, TypeAlias
if sys.version_info >= (3, 9):
__all__ = [
@@ -53,11 +53,11 @@ _N = TypeVar("_N")
# "store_false", "append", "append_const", "count", "help", "version",
# "extend"], but using this would make it hard to annotate callers
# that don't use a literal argument
_ActionStr = str
_ActionStr: TypeAlias = str
# more precisely, Literal["?", "*", "+", "...", "A...",
# "==SUPPRESS=="], but using this would make it hard to annotate
# callers that don't use a literal argument
_NArgsStr = str
_NArgsStr: TypeAlias = str
ONE_OR_MORE: Literal["+"]
OPTIONAL: Literal["?"]