Skip to content

chore(pre-commit.ci): pre-commit autoupdate #1549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
rev: v0.11.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def build_extensions(self) -> None:


def build(setup_kwargs: Any) -> None:
if os.environ.get("SKIP_CYTHON", False):
if os.environ.get("SKIP_CYTHON"):
return
try:
from Cython.Build import cythonize
Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/_services/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def generate_service_query(
if not qu_question and question_history.suppresses(question, now_millis, known_answers):
log.debug("Asking %s was suppressed by the question history", question)
continue
if TYPE_CHECKING: # noqa: SIM108
if TYPE_CHECKING:
pointer_known_answers = cast(set[DNSPointer], known_answers)
else:
pointer_known_answers = known_answers
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from unittest import mock

import ifaddr

from zeroconf import DNSIncoming, DNSQuestion, DNSRecord, Zeroconf
from zeroconf._history import QuestionHistory

Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from pytest_codspeed import BenchmarkFixture

from zeroconf import DNSCache, DNSPointer, current_time_millis
from zeroconf.const import _CLASS_IN, _TYPE_PTR

Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/test_incoming.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import socket

from pytest_codspeed import BenchmarkFixture

from zeroconf import (
DNSAddress,
DNSIncoming,
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/test_outgoing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from pytest_codspeed import BenchmarkFixture

from zeroconf._protocol.outgoing import State

from .helpers import generate_packets
Expand Down
3 changes: 2 additions & 1 deletion tests/benchmarks/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import pytest
from pytest_codspeed import BenchmarkFixture

from zeroconf.asyncio import AsyncZeroconf

from .helpers import generate_packets


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_sending_packets(benchmark: BenchmarkFixture) -> None:
"""Benchmark sending packets."""
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/test_txt_properties.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from pytest_codspeed import BenchmarkFixture

from zeroconf import ServiceInfo

info = ServiceInfo(
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from unittest.mock import patch

import pytest

from zeroconf import _core, const
from zeroconf._handlers import query_handler

Expand All @@ -19,7 +20,7 @@ def verify_threads_ended():
assert not threads


@pytest.fixture()
@pytest.fixture
def run_isolated():
"""Change the mDNS port to run the test in isolation."""
with (
Expand All @@ -30,7 +31,7 @@ def run_isolated():
yield


@pytest.fixture()
@pytest.fixture
def disable_duplicate_packet_suppression():
"""Disable duplicate packet suppress.

Expand Down
21 changes: 11 additions & 10 deletions tests/services/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from unittest.mock import patch

import pytest

import zeroconf as r
import zeroconf._services.browser as _services_browser
from zeroconf import (
Expand Down Expand Up @@ -555,7 +556,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
zeroconf_browser.close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_asking_default_is_asking_qm_questions_after_the_first_qu():
"""Verify the service browser's first questions are QU and refresh queries are QM."""
service_added = asyncio.Event()
Expand Down Expand Up @@ -657,7 +658,7 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ttl_refresh_cancelled_rescue_query():
"""Verify seeing a name again cancels the rescue query."""
service_added = asyncio.Event()
Expand Down Expand Up @@ -767,7 +768,7 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_asking_qm_questions():
"""Verify explicitly asking QM questions."""
type_ = "_quservice._tcp.local."
Expand Down Expand Up @@ -806,7 +807,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_asking_qu_questions():
"""Verify the service browser can ask QU questions."""
type_ = "_quservice._tcp.local."
Expand Down Expand Up @@ -898,7 +899,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):

browser.cancel()

assert len(updates)
assert updates
assert len([isinstance(update, r.DNSPointer) and update.name == type_ for update in updates]) >= 1

zc.remove_listener(listener)
Expand Down Expand Up @@ -1138,7 +1139,7 @@ def test_group_ptr_queries_with_known_answers():

# This test uses asyncio because it needs to access the cache directly
# which is not threadsafe
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_generate_service_query_suppress_duplicate_questions():
"""Generate a service query for sending with zeroconf.send."""
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
Expand Down Expand Up @@ -1191,7 +1192,7 @@ async def test_generate_service_query_suppress_duplicate_questions():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_query_scheduler():
delay = const._BROWSER_TIME
types_ = {"_hap._tcp.local.", "_http._tcp.local."}
Expand Down Expand Up @@ -1284,7 +1285,7 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_query_scheduler_rescue_records():
delay = const._BROWSER_TIME
types_ = {"_hap._tcp.local.", "_http._tcp.local."}
Expand Down Expand Up @@ -1579,7 +1580,7 @@ def test_scheduled_ptr_query_dunder_methods():
assert query75 >= other # type: ignore[operator]


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_close_zeroconf_without_browser_before_start_up_queries():
"""Test that we stop sending startup queries if zeroconf is closed out from under the browser."""
service_added = asyncio.Event()
Expand Down Expand Up @@ -1647,7 +1648,7 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
await browser.async_cancel()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_close_zeroconf_without_browser_after_start_up_queries():
"""Test that we stop sending rescue queries if zeroconf is closed out from under the browser."""
service_added = asyncio.Event()
Expand Down
33 changes: 17 additions & 16 deletions tests/services/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from unittest.mock import patch

import pytest

import zeroconf as r
from zeroconf import DNSAddress, RecordUpdate, const
from zeroconf._services import info
Expand Down Expand Up @@ -827,7 +828,7 @@ def test_scoped_addresses_from_cache():

# This test uses asyncio because it needs to access the cache directly
# which is not threadsafe
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_multiple_a_addresses_newest_address_first():
"""Test that info.addresses returns the newest seen address first."""
type_ = "_http._tcp.local."
Expand All @@ -847,7 +848,7 @@ async def test_multiple_a_addresses_newest_address_first():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_invalid_a_addresses(caplog):
type_ = "_http._tcp.local."
registration_name = f"multiarec.{type_}"
Expand Down Expand Up @@ -1056,7 +1057,7 @@ def test_request_timeout():
assert (end_time - start_time) < 3000 + 1000


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_we_try_four_times_with_random_delay():
"""Verify we try four times even with the random delay."""
type_ = "_typethatisnothere._tcp.local."
Expand All @@ -1079,7 +1080,7 @@ def async_send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT):
assert request_count == 4


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_release_wait_when_new_recorded_added():
"""Test that async_request returns as soon as new matching records are added to the cache."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1144,7 +1145,7 @@ async def test_release_wait_when_new_recorded_added():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_port_changes_are_seen():
"""Test that port changes are seen by async_request."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1227,7 +1228,7 @@ async def test_port_changes_are_seen():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_port_changes_are_seen_with_directed_request():
"""Test that port changes are seen by async_request with a directed request."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1310,7 +1311,7 @@ async def test_port_changes_are_seen_with_directed_request():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ipv4_changes_are_seen():
"""Test that ipv4 changes are seen by async_request."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1398,7 +1399,7 @@ async def test_ipv4_changes_are_seen():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ipv6_changes_are_seen():
"""Test that ipv6 changes are seen by async_request."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1493,7 +1494,7 @@ async def test_ipv6_changes_are_seen():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_bad_ip_addresses_ignored_in_cache():
"""Test that bad ip address in the cache are ignored async_request."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1547,7 +1548,7 @@ async def test_bad_ip_addresses_ignored_in_cache():
assert info.addresses_by_version(IPVersion.V4Only) == [b"\x7f\x00\x00\x01"]


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_service_name_change_as_seen_has_ip_in_cache():
"""Test that service name changes are seen by async_request when the ip is in the cache."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1629,7 +1630,7 @@ async def test_service_name_change_as_seen_has_ip_in_cache():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_service_name_change_as_seen_ip_not_in_cache():
"""Test that service name changes are seen by async_request when the ip is not in the cache."""
type_ = "_http._tcp.local."
Expand Down Expand Up @@ -1711,7 +1712,7 @@ async def test_service_name_change_as_seen_ip_not_in_cache():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
@patch.object(info, "_LISTENER_TIME", 10000000)
async def test_release_wait_when_new_recorded_added_concurrency():
"""Test that concurrent async_request returns as soon as new matching records are added to the cache."""
Expand Down Expand Up @@ -1783,7 +1784,7 @@ async def test_release_wait_when_new_recorded_added_concurrency():
await aiozc.async_close()


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_service_info_nsec_records():
"""Test we can generate nsec records from ServiceInfo."""
type_ = "_http._tcp.local."
Expand All @@ -1798,7 +1799,7 @@ async def test_service_info_nsec_records():
assert nsec_record.rdtypes == [const._TYPE_A, const._TYPE_AAAA]


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_address_resolver():
"""Test that the address resolver works."""
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
Expand All @@ -1822,7 +1823,7 @@ async def test_address_resolver():
assert resolver.addresses == [b"\x7f\x00\x00\x01"]


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_address_resolver_ipv4():
"""Test that the IPv4 address resolver works."""
aiozc = AsyncZeroconf(interfaces=["127.0.0.1"])
Expand All @@ -1846,7 +1847,7 @@ async def test_address_resolver_ipv4():
assert resolver.addresses == [b"\x7f\x00\x00\x01"]


@pytest.mark.asyncio()
@pytest.mark.asyncio
@unittest.skipIf(not has_working_ipv6(), "Requires IPv6")
@unittest.skipIf(os.environ.get("SKIP_IPV6"), "IPv6 tests disabled")
async def test_address_resolver_ipv6():
Expand Down
Loading
Loading