Right now the type annotations for the ipaddress.ip_network function only allow its argument to be one of an int, a str, bytes, an IPv4Address/IPv6Address, or an existing network.
However, currently the ipaddress.ip_network function also supports a Tuple[IPv4Address | IPv6Address | str | int | bytes, int] as an argument, in which case the first element becomes the base address and the second becomes the network prefix length:
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.ip_network(('192.168.1.0', 24))
IPv4Network('192.168.1.0/24')
>>> ipaddress.ip_network((0, 24))
IPv4Network('0.0.0.0/24')
Right now the type annotations for the
ipaddress.ip_networkfunction only allow its argument to be one of anint, astr,bytes, anIPv4Address/IPv6Address, or an existing network.However, currently the
ipaddress.ip_networkfunction also supports aTuple[IPv4Address | IPv6Address | str | int | bytes, int]as an argument, in which case the first element becomes the base address and the second becomes the network prefix length: