Address parameter of datagram_received can be of type tuple[int, int] (#7366)

This commit is contained in:
Thomas Cellerier
2022-02-23 12:09:26 +01:00
committed by GitHub
parent 4781dbf752
commit 09a1932e68

View File

@@ -1,5 +1,6 @@
import sys
from asyncio import transports
from typing import Any
if sys.version_info >= (3, 7):
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
@@ -24,7 +25,11 @@ if sys.version_info >= (3, 7):
class DatagramProtocol(BaseProtocol):
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
def datagram_received(self, data: bytes, addr: tuple[str, int]) -> None: ...
# addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK.
# Use tuple[str | Any, int] to not cause typechecking issues on most usual cases.
# 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 error_received(self, exc: Exception) -> None: ...
class SubprocessProtocol(BaseProtocol):