|
1 | 1 | """Unit tests for zeroconf._services.info.""" |
2 | 2 |
|
| 3 | +from __future__ import annotations |
| 4 | + |
3 | 5 | import asyncio |
4 | 6 | import logging |
5 | 7 | import os |
6 | 8 | import socket |
7 | 9 | import threading |
8 | 10 | import unittest |
| 11 | +from collections.abc import Iterable |
9 | 12 | from ipaddress import ip_address |
10 | 13 | from threading import Event |
11 | | -from typing import Iterable, List, Optional |
12 | 14 | from unittest.mock import patch |
13 | 15 |
|
14 | 16 | import pytest |
@@ -264,7 +266,7 @@ def test_get_info_partial(self): |
264 | 266 | send_event = Event() |
265 | 267 | service_info_event = Event() |
266 | 268 |
|
267 | | - last_sent: Optional[r.DNSOutgoing] = None |
| 269 | + last_sent: r.DNSOutgoing | None = None |
268 | 270 |
|
269 | 271 | def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): |
270 | 272 | """Sends an outgoing packet.""" |
@@ -407,7 +409,7 @@ def test_get_info_suppressed_by_question_history(self): |
407 | 409 | send_event = Event() |
408 | 410 | service_info_event = Event() |
409 | 411 |
|
410 | | - last_sent: Optional[r.DNSOutgoing] = None |
| 412 | + last_sent: r.DNSOutgoing | None = None |
411 | 413 |
|
412 | 414 | def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): |
413 | 415 | """Sends an outgoing packet.""" |
@@ -534,7 +536,7 @@ def test_get_info_single(self): |
534 | 536 | send_event = Event() |
535 | 537 | service_info_event = Event() |
536 | 538 |
|
537 | | - last_sent = None # type: Optional[r.DNSOutgoing] |
| 539 | + last_sent: r.DNSOutgoing | None = None |
538 | 540 |
|
539 | 541 | def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): |
540 | 542 | """Sends an outgoing packet.""" |
@@ -879,7 +881,7 @@ def test_filter_address_by_type_from_service_info(): |
879 | 881 | ipv6 = socket.inet_pton(socket.AF_INET6, "2001:db8::1") |
880 | 882 | info = ServiceInfo(type_, registration_name, 80, 0, 0, desc, "ash-2.local.", addresses=[ipv4, ipv6]) |
881 | 883 |
|
882 | | - def dns_addresses_to_addresses(dns_address: List[DNSAddress]) -> List[bytes]: |
| 884 | + def dns_addresses_to_addresses(dns_address: list[DNSAddress]) -> list[bytes]: |
883 | 885 | return [address.address for address in dns_address] |
884 | 886 |
|
885 | 887 | assert dns_addresses_to_addresses(info.dns_addresses()) == [ipv4, ipv6] |
|
0 commit comments