feat: migrate to native types (#1472) · python-zeroconf/python-zeroconf@22a0fb4
11"""Unit tests for zeroconf._services.info."""
223+from __future__ import annotations
4+35import asyncio
46import logging
57import os
68import socket
79import threading
810import unittest
11+from collections.abc import Iterable
912from ipaddress import ip_address
1013from threading import Event
11-from typing import Iterable, List, Optional
1214from unittest.mock import patch
13151416import pytest
@@ -264,7 +266,7 @@ def test_get_info_partial(self):
264266send_event = Event()
265267service_info_event = Event()
266268267-last_sent: Optional[r.DNSOutgoing] = None
269+last_sent: r.DNSOutgoing | None = None
268270269271def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
270272"""Sends an outgoing packet."""
@@ -407,7 +409,7 @@ def test_get_info_suppressed_by_question_history(self):
407409send_event = Event()
408410service_info_event = Event()
409411410-last_sent: Optional[r.DNSOutgoing] = None
412+last_sent: r.DNSOutgoing | None = None
411413412414def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
413415"""Sends an outgoing packet."""
@@ -534,7 +536,7 @@ def test_get_info_single(self):
534536send_event = Event()
535537service_info_event = Event()
536538537-last_sent = None # type: Optional[r.DNSOutgoing]
539+last_sent: r.DNSOutgoing | None = None
538540539541def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
540542"""Sends an outgoing packet."""
@@ -879,7 +881,7 @@ def test_filter_address_by_type_from_service_info():
879881ipv6 = socket.inet_pton(socket.AF_INET6, "2001:db8::1")
880882info = ServiceInfo(type_, registration_name, 80, 0, 0, desc, "ash-2.local.", addresses=[ipv4, ipv6])
881883882-def dns_addresses_to_addresses(dns_address: List[DNSAddress]) -> List[bytes]:
884+def dns_addresses_to_addresses(dns_address: list[DNSAddress]) -> list[bytes]:
883885return [address.address for address in dns_address]
884886885887assert dns_addresses_to_addresses(info.dns_addresses()) == [ipv4, ipv6]