Skip to content

ipaddress.ip_network annotations ban tuple arguments #8570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ischeinkman opened this issue Aug 19, 2022 · 1 comment · Fixed by #8634
Closed

ipaddress.ip_network annotations ban tuple arguments #8570

ischeinkman opened this issue Aug 19, 2022 · 1 comment · Fixed by #8634
Labels
stubs: false positive Type checkers report false errors

Comments

@ischeinkman
Copy link

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')
@Akuli
Copy link
Collaborator

Akuli commented Aug 19, 2022

Thanks. PR welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants