From af688edf5e767f4a93f49fe1e1cbe3e7ee3c7839 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:49:51 +0000 Subject: [PATCH 1/2] chore(pre-commit.ci): pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.4...v0.8.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e3e7556..3dfc075e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.0 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 39a0d424b06a78dc61db879300a84195a89ac4fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:50:06 +0000 Subject: [PATCH 2/2] chore(pre-commit.ci): auto fixes --- src/zeroconf/__init__.py | 28 ++++++++-------- src/zeroconf/_dns.py | 8 ++--- src/zeroconf/_engine.py | 10 +++--- src/zeroconf/_handlers/answers.py | 4 +-- .../_handlers/multicast_outgoing_queue.py | 8 ++--- src/zeroconf/_handlers/query_handler.py | 22 ++++++------- src/zeroconf/_handlers/record_manager.py | 2 +- src/zeroconf/_listener.py | 14 ++++---- src/zeroconf/_protocol/incoming.py | 24 +++++++------- src/zeroconf/_protocol/outgoing.py | 16 +++++----- src/zeroconf/_services/browser.py | 30 ++++++++--------- src/zeroconf/_services/info.py | 32 +++++++++---------- src/zeroconf/_services/registry.py | 2 +- src/zeroconf/_transport.py | 4 +-- src/zeroconf/_utils/ipaddress.py | 4 +-- src/zeroconf/asyncio.py | 4 +-- 16 files changed, 106 insertions(+), 106 deletions(-) diff --git a/src/zeroconf/__init__.py b/src/zeroconf/__init__.py index 9df63ad1..e93eb4d2 100644 --- a/src/zeroconf/__init__.py +++ b/src/zeroconf/__init__.py @@ -88,27 +88,27 @@ __all__ = [ - "__version__", - "Zeroconf", - "ServiceInfo", - "ServiceBrowser", - "ServiceListener", + "AbstractMethodException", + "BadTypeInNameException", "DNSQuestionType", - "InterfaceChoice", - "ServiceStateChange", - "IPVersion", - "ZeroconfServiceTypes", - "RecordUpdate", - "RecordUpdateListener", - "current_time_millis", # Exceptions "Error", - "AbstractMethodException", - "BadTypeInNameException", "EventLoopBlocked", + "IPVersion", "IncomingDecodeError", + "InterfaceChoice", "NamePartTooLongException", "NonUniqueNameException", "NotRunningException", + "RecordUpdate", + "RecordUpdateListener", + "ServiceBrowser", + "ServiceInfo", + "ServiceListener", "ServiceNameAlreadyRegistered", + "ServiceStateChange", + "Zeroconf", + "ZeroconfServiceTypes", + "__version__", + "current_time_millis", ] diff --git a/src/zeroconf/_dns.py b/src/zeroconf/_dns.py index 15daa709..fe48a2f4 100644 --- a/src/zeroconf/_dns.py +++ b/src/zeroconf/_dns.py @@ -64,7 +64,7 @@ class DNSQuestionType(enum.Enum): class DNSEntry: """A DNS entry""" - __slots__ = ("key", "name", "type", "class_", "unique") + __slots__ = ("class_", "key", "name", "type", "unique") def __init__(self, name: str, type_: int, class_: int) -> None: self.name = name @@ -157,7 +157,7 @@ def __repr__(self) -> str: class DNSRecord(DNSEntry): """A DNS record - like a DNS entry, but has a TTL""" - __slots__ = ("ttl", "created") + __slots__ = ("created", "ttl") # TODO: Switch to just int ttl def __init__( @@ -421,7 +421,7 @@ def __repr__(self) -> str: class DNSService(DNSRecord): """A DNS service record""" - __slots__ = ("_hash", "priority", "weight", "port", "server", "server_key") + __slots__ = ("_hash", "port", "priority", "server", "server_key", "weight") def __init__( self, @@ -542,7 +542,7 @@ def __repr__(self) -> str: class DNSRRSet: """A set of dns records with a lookup to get the ttl.""" - __slots__ = ("_records", "_lookup") + __slots__ = ("_lookup", "_records") def __init__(self, records: List[DNSRecord]) -> None: """Create an RRset from records sets.""" diff --git a/src/zeroconf/_engine.py b/src/zeroconf/_engine.py index e807d9ef..05f8c948 100644 --- a/src/zeroconf/_engine.py +++ b/src/zeroconf/_engine.py @@ -45,15 +45,15 @@ class AsyncEngine: """An engine wraps sockets in the event loop.""" __slots__ = ( + "_cleanup_timer", + "_listen_socket", + "_respond_sockets", "loop", - "zc", "protocols", "readers", - "senders", "running_event", - "_listen_socket", - "_respond_sockets", - "_cleanup_timer", + "senders", + "zc", ) def __init__( diff --git a/src/zeroconf/_handlers/answers.py b/src/zeroconf/_handlers/answers.py index bab2d749..7ddde197 100644 --- a/src/zeroconf/_handlers/answers.py +++ b/src/zeroconf/_handlers/answers.py @@ -44,7 +44,7 @@ class QuestionAnswers: """A group of answers to a question.""" - __slots__ = ("ucast", "mcast_now", "mcast_aggregate", "mcast_aggregate_last_second") + __slots__ = ("mcast_aggregate", "mcast_aggregate_last_second", "mcast_now", "ucast") def __init__( self, @@ -71,7 +71,7 @@ def __repr__(self) -> str: class AnswerGroup: """A group of answers scheduled to be sent at the same time.""" - __slots__ = ("send_after", "send_before", "answers") + __slots__ = ("answers", "send_after", "send_before") def __init__( self, diff --git a/src/zeroconf/_handlers/multicast_outgoing_queue.py b/src/zeroconf/_handlers/multicast_outgoing_queue.py index afcefc01..caf6470b 100644 --- a/src/zeroconf/_handlers/multicast_outgoing_queue.py +++ b/src/zeroconf/_handlers/multicast_outgoing_queue.py @@ -45,12 +45,12 @@ class MulticastOutgoingQueue: """An outgoing queue used to aggregate multicast responses.""" __slots__ = ( - "zc", - "queue", - "_multicast_delay_random_min", - "_multicast_delay_random_max", "_additional_delay", "_aggregation_delay", + "_multicast_delay_random_max", + "_multicast_delay_random_min", + "queue", + "zc", ) def __init__(self, zeroconf: "Zeroconf", additional_delay: _int, max_aggregation_delay: _int) -> None: diff --git a/src/zeroconf/_handlers/query_handler.py b/src/zeroconf/_handlers/query_handler.py index 3acb1b44..ccfc7a77 100644 --- a/src/zeroconf/_handlers/query_handler.py +++ b/src/zeroconf/_handlers/query_handler.py @@ -71,7 +71,7 @@ class _AnswerStrategy: - __slots__ = ("question", "strategy_type", "types", "services") + __slots__ = ("question", "services", "strategy_type", "types") def __init__( self, @@ -91,15 +91,15 @@ class _QueryResponse: """A pair for unicast and multicast DNSOutgoing responses.""" __slots__ = ( - "_is_probe", - "_questions", - "_now", - "_cache", "_additionals", - "_ucast", - "_mcast_now", + "_cache", + "_is_probe", "_mcast_aggregate", "_mcast_aggregate_last_second", + "_mcast_now", + "_now", + "_questions", + "_ucast", ) def __init__(self, cache: DNSCache, questions: List[DNSQuestion], is_probe: bool, now: float) -> None: @@ -191,12 +191,12 @@ class QueryHandler: """Query the ServiceRegistry.""" __slots__ = ( - "zc", - "registry", "cache", - "question_history", - "out_queue", "out_delay_queue", + "out_queue", + "question_history", + "registry", + "zc", ) def __init__(self, zc: "Zeroconf") -> None: diff --git a/src/zeroconf/_handlers/record_manager.py b/src/zeroconf/_handlers/record_manager.py index 53ab3ed1..0bb04996 100644 --- a/src/zeroconf/_handlers/record_manager.py +++ b/src/zeroconf/_handlers/record_manager.py @@ -40,7 +40,7 @@ class RecordManager: """Process records into the cache and notify listeners.""" - __slots__ = ("zc", "cache", "listeners") + __slots__ = ("cache", "listeners", "zc") def __init__(self, zeroconf: "Zeroconf") -> None: """Init the record manager.""" diff --git a/src/zeroconf/_listener.py b/src/zeroconf/_listener.py index 4490965f..1980a820 100644 --- a/src/zeroconf/_listener.py +++ b/src/zeroconf/_listener.py @@ -55,17 +55,17 @@ class AsyncListener: the read() method called when a socket is available for reading.""" __slots__ = ( - "zc", - "_registry", - "_record_manager", + "_deferred", "_query_handler", + "_record_manager", + "_registry", + "_timers", "data", - "last_time", "last_message", - "transport", + "last_time", "sock_description", - "_deferred", - "_timers", + "transport", + "zc", ) def __init__(self, zc: "Zeroconf") -> None: diff --git a/src/zeroconf/_protocol/incoming.py b/src/zeroconf/_protocol/incoming.py index f7b1d773..d678c977 100644 --- a/src/zeroconf/_protocol/incoming.py +++ b/src/zeroconf/_protocol/incoming.py @@ -70,25 +70,25 @@ class DNSIncoming: """Object representation of an incoming DNS packet""" __slots__ = ( - "_did_read_others", - "flags", - "offset", - "data", - "view", + "_answers", "_data_len", + "_did_read_others", + "_has_qu_question", "_name_cache", - "_questions", - "_answers", - "id", - "_num_questions", + "_num_additionals", "_num_answers", "_num_authorities", - "_num_additionals", - "valid", + "_num_questions", + "_questions", + "data", + "flags", + "id", "now", + "offset", "scope_id", "source", - "_has_qu_question", + "valid", + "view", ) def __init__( diff --git a/src/zeroconf/_protocol/outgoing.py b/src/zeroconf/_protocol/outgoing.py index 9e9a5c87..b2eb9230 100644 --- a/src/zeroconf/_protocol/outgoing.py +++ b/src/zeroconf/_protocol/outgoing.py @@ -77,20 +77,20 @@ class DNSOutgoing: """Object representation of an outgoing packet""" __slots__ = ( - "flags", + "additionals", + "allow_long", + "answers", + "authorities", + "data", "finished", + "flags", "id", "multicast", - "packets_data", "names", - "data", + "packets_data", + "questions", "size", - "allow_long", "state", - "questions", - "answers", - "authorities", - "additionals", ) def __init__(self, flags: int, multicast: bool = True, id_: int = 0) -> None: diff --git a/src/zeroconf/_services/browser.py b/src/zeroconf/_services/browser.py index 30361528..42aaa1ac 100644 --- a/src/zeroconf/_services/browser.py +++ b/src/zeroconf/_services/browser.py @@ -107,10 +107,10 @@ class _ScheduledPTRQuery: __slots__ = ( "alias", - "name", - "ttl", "cancelled", "expire_time_millis", + "name", + "ttl", "when_millis", ) @@ -189,7 +189,7 @@ def __gt__(self, other: "_ScheduledPTRQuery") -> bool: class _DNSPointerOutgoingBucket: """A DNSOutgoing bucket.""" - __slots__ = ("now_millis", "out", "bytes") + __slots__ = ("bytes", "now_millis", "out") def __init__(self, now_millis: float, multicast: bool) -> None: """Create a bucket to wrap a DNSOutgoing.""" @@ -328,20 +328,20 @@ class QueryScheduler: """ __slots__ = ( - "_zc", - "_types", "_addr", - "_port", - "_multicast", + "_clock_resolution_millis", "_first_random_delay_interval", - "_min_time_between_queries_millis", "_loop", - "_startup_queries_sent", + "_min_time_between_queries_millis", + "_multicast", + "_next_run", "_next_scheduled_for_alias", + "_port", "_query_heap", - "_next_run", - "_clock_resolution_millis", "_question_type", + "_startup_queries_sent", + "_types", + "_zc", ) def __init__( @@ -556,15 +556,15 @@ class _ServiceBrowserBase(RecordUpdateListener): """Base class for ServiceBrowser.""" __slots__ = ( - "types", - "zc", "_cache", "_loop", "_pending_handlers", + "_query_sender_task", "_service_state_changed", - "query_scheduler", "done", - "_query_sender_task", + "query_scheduler", + "types", + "zc", ) def __init__( diff --git a/src/zeroconf/_services/info.py b/src/zeroconf/_services/info.py index 8a85ad10..f47addf6 100644 --- a/src/zeroconf/_services/info.py +++ b/src/zeroconf/_services/info.py @@ -138,28 +138,28 @@ class ServiceInfo(RecordUpdateListener): """ __slots__ = ( - "text", - "type", - "_name", - "key", + "_decoded_properties", + "_dns_address_cache", + "_dns_pointer_cache", + "_dns_service_cache", + "_dns_text_cache", + "_get_address_and_nsec_records_cache", "_ipv4_addresses", "_ipv6_addresses", + "_name", + "_new_records_futures", + "_properties", + "host_ttl", + "interface_index", + "key", + "other_ttl", "port", - "weight", "priority", "server", "server_key", - "_properties", - "_decoded_properties", - "host_ttl", - "other_ttl", - "interface_index", - "_new_records_futures", - "_dns_pointer_cache", - "_dns_service_cache", - "_dns_text_cache", - "_dns_address_cache", - "_get_address_and_nsec_records_cache", + "text", + "type", + "weight", ) def __init__( diff --git a/src/zeroconf/_services/registry.py b/src/zeroconf/_services/registry.py index 05ee14cb..4100c690 100644 --- a/src/zeroconf/_services/registry.py +++ b/src/zeroconf/_services/registry.py @@ -35,7 +35,7 @@ class ServiceRegistry: the event loop as it is not thread safe. """ - __slots__ = ("_services", "types", "servers", "has_entries") + __slots__ = ("_services", "has_entries", "servers", "types") def __init__( self, diff --git a/src/zeroconf/_transport.py b/src/zeroconf/_transport.py index f28c0029..b0811094 100644 --- a/src/zeroconf/_transport.py +++ b/src/zeroconf/_transport.py @@ -29,11 +29,11 @@ class _WrappedTransport: """A wrapper for transports.""" __slots__ = ( - "transport", + "fileno", "is_ipv6", "sock", - "fileno", "sock_name", + "transport", ) def __init__( diff --git a/src/zeroconf/_utils/ipaddress.py b/src/zeroconf/_utils/ipaddress.py index 72bb9ce8..8dc1f797 100644 --- a/src/zeroconf/_utils/ipaddress.py +++ b/src/zeroconf/_utils/ipaddress.py @@ -39,7 +39,7 @@ class ZeroconfIPv4Address(IPv4Address): - __slots__ = ("_str", "_is_link_local", "_is_unspecified", "_is_loopback", "__hash__", "zc_integer") + __slots__ = ("__hash__", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer") def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize a new IPv4 address.""" @@ -72,7 +72,7 @@ def is_loopback(self) -> bool: class ZeroconfIPv6Address(IPv6Address): - __slots__ = ("_str", "_is_link_local", "_is_unspecified", "_is_loopback", "__hash__", "zc_integer") + __slots__ = ("__hash__", "_is_link_local", "_is_loopback", "_is_unspecified", "_str", "zc_integer") def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize a new IPv6 address.""" diff --git a/src/zeroconf/asyncio.py b/src/zeroconf/asyncio.py index 134ea3e0..926ef509 100644 --- a/src/zeroconf/asyncio.py +++ b/src/zeroconf/asyncio.py @@ -35,9 +35,9 @@ from .const import _BROWSER_TIME, _MDNS_PORT, _SERVICE_TYPE_ENUMERATION_NAME __all__ = [ - "AsyncZeroconf", - "AsyncServiceInfo", "AsyncServiceBrowser", + "AsyncServiceInfo", + "AsyncZeroconf", "AsyncZeroconfServiceTypes", ]