Skip to content

Commit bcf4a44

Browse files
authored
chore: fix missed future annotations (#1503)
1 parent 64138a3 commit bcf4a44

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

src/zeroconf/_listener.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
USA
2121
"""
2222

23+
from __future__ import annotations
24+
2325
import asyncio
2426
import logging
2527
import random
2628
from functools import partial
27-
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union, cast
29+
from typing import TYPE_CHECKING, Tuple, cast
2830

2931
from ._logger import QuietLogger, log
3032
from ._protocol.incoming import DNSIncoming
@@ -68,23 +70,21 @@ class AsyncListener:
6870
"zc",
6971
)
7072

71-
def __init__(self, zc: "Zeroconf") -> None:
73+
def __init__(self, zc: Zeroconf) -> None:
7274
self.zc = zc
7375
self._registry = zc.registry
7476
self._record_manager = zc.record_manager
7577
self._query_handler = zc.query_handler
76-
self.data: Optional[bytes] = None
78+
self.data: bytes | None = None
7779
self.last_time: float = 0
78-
self.last_message: Optional[DNSIncoming] = None
79-
self.transport: Optional[_WrappedTransport] = None
80-
self.sock_description: Optional[str] = None
81-
self._deferred: Dict[str, List[DNSIncoming]] = {}
82-
self._timers: Dict[str, asyncio.TimerHandle] = {}
80+
self.last_message: DNSIncoming | None = None
81+
self.transport: _WrappedTransport | None = None
82+
self.sock_description: str | None = None
83+
self._deferred: dict[str, list[DNSIncoming]] = {}
84+
self._timers: dict[str, asyncio.TimerHandle] = {}
8385
super().__init__()
8486

85-
def datagram_received(
86-
self, data: _bytes, addrs: Union[Tuple[str, int], Tuple[str, int, int, int]]
87-
) -> None:
87+
def datagram_received(self, data: _bytes, addrs: tuple[str, int] | tuple[str, int, int, int]) -> None:
8888
data_len = len(data)
8989
debug = DEBUG_ENABLED()
9090

@@ -108,7 +108,7 @@ def _process_datagram_at_time(
108108
data_len: _int,
109109
now: _float,
110110
data: _bytes,
111-
addrs: Union[Tuple[str, int], Tuple[str, int, int, int]],
111+
addrs: tuple[str, int] | tuple[str, int, int, int],
112112
) -> None:
113113
if (
114114
self.data == data
@@ -129,7 +129,7 @@ def _process_datagram_at_time(
129129
return
130130

131131
if len(addrs) == 2:
132-
v6_flow_scope: Union[Tuple[()], Tuple[int, int]] = ()
132+
v6_flow_scope: tuple[()] | tuple[int, int] = ()
133133
# https://github.com/python/mypy/issues/1178
134134
addr, port = addrs # type: ignore
135135
addr_port = addrs
@@ -189,7 +189,7 @@ def handle_query_or_defer(
189189
addr: _str,
190190
port: _int,
191191
transport: _WrappedTransport,
192-
v6_flow_scope: Union[Tuple[()], Tuple[int, int]],
192+
v6_flow_scope: tuple[()] | tuple[int, int],
193193
) -> None:
194194
"""Deal with incoming query packets. Provides a response if
195195
possible."""
@@ -224,11 +224,11 @@ def _cancel_any_timers_for_addr(self, addr: _str) -> None:
224224

225225
def _respond_query(
226226
self,
227-
msg: Optional[DNSIncoming],
227+
msg: DNSIncoming | None,
228228
addr: _str,
229229
port: _int,
230230
transport: _WrappedTransport,
231-
v6_flow_scope: Union[Tuple[()], Tuple[int, int]],
231+
v6_flow_scope: tuple[()] | tuple[int, int],
232232
) -> None:
233233
"""Respond to a query and reassemble any truncated deferred packets."""
234234
self._cancel_any_timers_for_addr(addr)
@@ -252,5 +252,5 @@ def connection_made(self, transport: asyncio.BaseTransport) -> None:
252252
self.transport = wrapped_transport
253253
self.sock_description = f"{wrapped_transport.fileno} ({wrapped_transport.sock_name})"
254254

255-
def connection_lost(self, exc: Optional[Exception]) -> None:
255+
def connection_lost(self, exc: Exception | None) -> None:
256256
"""Handle connection lost."""

0 commit comments

Comments
 (0)