Skip to content

Commit

Permalink
Move Literal type into TYPE_CHECKING block
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Dec 22, 2023
1 parent f4c7817 commit 47effd3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mreg_cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 47effd3

Please sign in to comment.