Make type annotations safe for Python 3.7.

This commit is contained in:
Dave Shawley 2021-03-30 08:09:53 -04:00
parent da95efa544
commit 51e1f2ccae
No known key found for this signature in database
GPG key ID: F41A8A99298F8EED
2 changed files with 3 additions and 3 deletions

View file

@ -333,7 +333,7 @@ class Processor:
logger: logging.Logger logger: logging.Logger
protocol: typing.Optional[StatsdProtocol] protocol: typing.Optional[StatsdProtocol]
queue: asyncio.Queue[bytes] queue: asyncio.Queue
_create_transport: typing.Callable[[], typing.Coroutine[ _create_transport: typing.Callable[[], typing.Coroutine[
typing.Any, typing.Any, typing.Tuple[asyncio.BaseTransport, typing.Any, typing.Any, typing.Tuple[asyncio.BaseTransport,
StatsdProtocol]]] StatsdProtocol]]]

View file

@ -20,7 +20,7 @@ class StatsdServer(asyncio.DatagramProtocol, asyncio.Protocol):
self.running = asyncio.Event() self.running = asyncio.Event()
self.client_connected = asyncio.Semaphore(value=0) self.client_connected = asyncio.Semaphore(value=0)
self.message_received = asyncio.Semaphore(value=0) self.message_received = asyncio.Semaphore(value=0)
self.transports: list[asyncio.BaseTransport] = [] self.transports: typing.List[asyncio.BaseTransport] = []
self._buffer = io.BytesIO() self._buffer = io.BytesIO()
@ -34,7 +34,7 @@ class StatsdServer(asyncio.DatagramProtocol, asyncio.Protocol):
self.port, self.port,
reuse_port=True) reuse_port=True)
self.server = server self.server = server
listening_sock = typing.cast(list[socket.socket], listening_sock = typing.cast(typing.List[socket.socket],
server.sockets)[0] server.sockets)[0]
self.host, self.port = listening_sock.getsockname() self.host, self.port = listening_sock.getsockname()
self.running.set() self.running.set()