fix socket type for python 3.8

This commit is contained in:
Jack Robison 2020-10-30 12:51:13 -04:00
parent d8098d8315
commit a33a3a3a83
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -3,6 +3,7 @@ import socket
import typing
from asyncio.protocols import DatagramProtocol
from asyncio.transports import DatagramTransport
from asyncio.trsock import TransportSocket
from unittest import mock
@ -10,7 +11,7 @@ def _get_sock(transport: typing.Optional[DatagramTransport]) -> typing.Optional[
if transport is None or not hasattr(transport, "_extra"):
return None
sock: typing.Optional[socket.socket] = transport.get_extra_info('socket', None)
assert sock is None or isinstance(sock, (socket.SocketType, mock.MagicMock))
assert sock is None or isinstance(sock, (socket.SocketType, TransportSocket, mock.MagicMock))
return sock