From 47effd3cc82accef665b32a4730f2b0936d3c51d Mon Sep 17 00:00:00 2001 From: pederhan Date: Fri, 22 Dec 2023 11:37:24 +0100 Subject: [PATCH] Move Literal type into TYPE_CHECKING block --- mreg_cli/types.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mreg_cli/types.py b/mreg_cli/types.py index c7dae43d..5b1ca392 100644 --- a/mreg_cli/types.py +++ b/mreg_cli/types.py @@ -44,9 +44,11 @@ class RecordingEntry(TypedDict): IP_Version: "TypeAlias" = "Literal[4, 6]" IP_networkT = TypeVar("IP_networkT", ipaddress.IPv4Network, ipaddress.IPv6Network) -# https://github.com/python/typeshed/blob/16933b838eef7be92ee02f66b87aa1a7532cee63/stdlib/argparse.pyi#L40-L43 -NargsStr = Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="] -NargsType = Union[int, NargsStr] + +if TYPE_CHECKING: + # https://github.com/python/typeshed/blob/16933b838eef7be92ee02f66b87aa1a7532cee63/stdlib/argparse.pyi#L40-L43 + NargsStr = Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="] + NargsType = Union[int, NargsStr] class Flag: @@ -57,13 +59,13 @@ def __init__( name: str, description: str = "", short_desc: str = "", - nargs: Optional[NargsType] = None, + nargs: Optional["NargsType"] = None, default: Any = None, flag_type: Any = None, choices: List[str] = None, required: bool = False, - metavar: str = None, - action: str = None, + metavar: Optional[str] = None, + action: Optional[str] = None, ): """Initialize a Flag object.""" self.name = name