feat: migrate to native types (#1472) · python-zeroconf/python-zeroconf@22a0fb4

11

"""Unit tests for zeroconf._services.info."""

223+

from __future__ import annotations

4+35

import asyncio

46

import logging

57

import os

68

import socket

79

import threading

810

import unittest

11+

from collections.abc import Iterable

912

from ipaddress import ip_address

1013

from threading import Event

11-

from typing import Iterable, List, Optional

1214

from unittest.mock import patch

13151416

import pytest

@@ -264,7 +266,7 @@ def test_get_info_partial(self):

264266

send_event = Event()

265267

service_info_event = Event()

266268267-

last_sent: Optional[r.DNSOutgoing] = None

269+

last_sent: r.DNSOutgoing | None = None

268270269271

def 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):

407409

send_event = Event()

408410

service_info_event = Event()

409411410-

last_sent: Optional[r.DNSOutgoing] = None

412+

last_sent: r.DNSOutgoing | None = None

411413412414

def 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):

534536

send_event = Event()

535537

service_info_event = Event()

536538537-

last_sent = None # type: Optional[r.DNSOutgoing]

539+

last_sent: r.DNSOutgoing | None = None

538540539541

def 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():

879881

ipv6 = socket.inet_pton(socket.AF_INET6, "2001:db8::1")

880882

info = 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]:

883885

return [address.address for address in dns_address]

884886885887

assert dns_addresses_to_addresses(info.dns_addresses()) == [ipv4, ipv6]