Skip to content

Commit

Permalink
Support a proper IP_Version type...
Browse files Browse the repository at this point in the history
  - Literal doesn't exist for <3.7, so there we use _int_. How quaint.
  • Loading branch information
terjekv committed Dec 11, 2023
1 parent ee81f5c commit f55ebd8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mreg_cli/types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
"""Typing definitions for mreg_cli."""
import ipaddress
import sys
from typing import TYPE_CHECKING, Union

# Horrible heck to support Literal on Python 3.6
if sys.version_info >= (3, 7):
from typing_extensions import Literal

IP_Version = Literal[4, 6]
else:
from typing import int

IP_Version = int

IP_network = Union[ipaddress.IPv4Network, ipaddress.IPv6Network]
# IP_Version = Literal[4, 6]
# IP_Version can be either 4 or 6, but Literal is not supported in older versions of Python.
# We could use typing_extensions.Literal, but that would require an extra dependency.
IP_Version = int


if TYPE_CHECKING:
Expand Down

0 comments on commit f55ebd8

Please sign in to comment.