Fix DatagramProtocol address type for IPv6 - #16116
Conversation
This comment has been minimized.
This comment has been minimized.
|
|
||
| protocol = asyncio.DatagramProtocol() | ||
| protocol.datagram_received(b"", ("127.0.0.1", 80)) | ||
| protocol.datagram_received(b"", ("::1", 80, 0, 0)) |
There was a problem hiding this comment.
Please remove the tests. In typeshed, we only add regression tests in cases where functions and classes which are known to have caused problems in the past, or where stubs are difficult to get right. 100% test coverage for typeshed is neither necessary nor desirable, as it would lead to code duplication.
See tests/REGRESSION.md for more information.
There was a problem hiding this comment.
Removed the regression test in c23e44a as requested.
| # This could be improved by using tuple[AnyOf[str, int], int] if the AnyOf feature is accepted. | ||
| # See https://github.com/python/typing/issues/566 | ||
| def datagram_received(self, data: bytes, addr: tuple[str | Any, int]) -> None: ... | ||
| def datagram_received(self, data: bytes, addr: tuple[str | Any, int] | tuple[str, int, int, int]) -> None: ... |
There was a problem hiding this comment.
I'm not sure this is the right approach. We should probably just use tuple[Any, ...] and explain the various possible tuples in the comment above. (We do that already to some extent.)
There was a problem hiding this comment.
Updated in c23e44a to use tuple[Any, ...], with the comment documenting the IPv4, IPv6, and AF_NETLINK tuple forms.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Summary
DatagramProtocol.datagram_received.Tests
pre-commit run --files stdlib/asyncio/protocols.pyi stdlib/@tests/test_cases/asyncio/check_protocols.pypython tests/runtests.py stdlib/asyncio_tkinterunavailable and missing_curses.BUTTON5_*)Fixes #15169