Skip to content

ipaddress.ip_network annotations ban tuple arguments #8570

Description

@ischeinkman

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions