Skip to content

ip_interface can have tuple arguments#9195

Merged
srittau merged 1 commit into
python:mainfrom
sobolevn:issue-8966
Nov 14, 2022
Merged

ip_interface can have tuple arguments#9195
srittau merged 1 commit into
python:mainfrom
sobolevn:issue-8966

Conversation

@sobolevn

Copy link
Copy Markdown
Member

Source: https://github.com/python/cpython/blob/main/Lib/ipaddress.py

Code:

>>> from ipaddress import ip_interface
>>> ip_interface(('192.0.2.0', 24))
IPv4Interface('192.0.2.0/24')
>>> ip_interface(('192.0.2.0', ))
IPv4Interface('192.0.2.0/32')

>>> from ipaddress import ip_address
>>> a = ip_address('192.0.2.0')
>>> ip_interface((a, ))
IPv4Interface('192.0.2.0/32')
>>> ip_interface((a, 24))
IPv4Interface('192.0.2.0/24')

>>> a.packed
b'\xc0\x00\x02\x00'
>>> ip_interface((a.packed, 24))
IPv4Interface('192.0.2.0/24')
>>> ip_interface((a.packed,))
IPv4Interface('192.0.2.0/32')

Closes #8966

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 0bd4e3c into python:main Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ip_interface function accepts tuples, typing does not

2 participants