Skip to content

Commit 6eabbc3

Browse files
authored
revert: remove derivative prose from the pyzeroconf era (#1847)
1 parent 55061e7 commit 6eabbc3

12 files changed

Lines changed: 7 additions & 416 deletions

File tree

‎examples/async_browser.py‎

Lines changed: 0 additions & 111 deletions
This file was deleted.

‎examples/async_registration.py‎

Lines changed: 0 additions & 75 deletions
This file was deleted.

‎src/zeroconf/_cache.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ def async_expire(self, now: _float) -> list[DNSRecord]:
210210
return expired
211211

212212
def async_get_unique(self, entry: _UniqueRecordsType) -> DNSRecord | None:
213-
"""Gets a unique entry by key. Will return None if there is no
214-
matching entry.
215-
216-
This function is not threadsafe and must be called from
217-
the event loop.
218-
"""
219213
store = self.cache.get(entry.key)
220214
if store is None:
221215
return None
@@ -238,19 +232,9 @@ def async_all_by_details(self, name: _str, type_: _int, class_: _int) -> list[DN
238232
return matches
239233

240234
def async_entries_with_name(self, name: str) -> list[DNSRecord]:
241-
"""Returns a dict of entries whose key matches the name.
242-
243-
This function is not threadsafe and must be called from
244-
the event loop.
245-
"""
246235
return self.entries_with_name(name)
247236

248237
def async_entries_with_server(self, name: str) -> list[DNSRecord]:
249-
"""Returns a dict of entries whose key matches the server.
250-
251-
This function is not threadsafe and must be called from
252-
the event loop.
253-
"""
254238
return self.entries_with_server(name)
255239

256240
# The below functions are threadsafe and do not need to be run in the
@@ -295,7 +279,6 @@ def get_all_by_details(self, name: str, type_: _int, class_: _int) -> list[DNSRe
295279
return [entry for entry in list(records.values()) if type_ == entry.type and class_ == entry.class_]
296280

297281
def entries_with_server(self, server: str) -> list[DNSRecord]:
298-
"""Returns a list of entries whose server matches the name."""
299282
if entries := self.service_cache.get(server.lower()):
300283
return list(entries.values())
301284
return []

‎src/zeroconf/_core.py‎

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ def listeners(self) -> set[RecordUpdateListener]:
280280
return self.record_manager.listeners
281281

282282
async def async_wait(self, timeout: float) -> None:
283-
"""Calling task waits for a given number of milliseconds or until notified."""
284283
loop = self.loop
285284
assert loop is not None
286285
await wait_for_future_set_or_timeout(loop, self._notify_futures, timeout)
@@ -303,15 +302,6 @@ def get_service_info(
303302
timeout: int = 3000,
304303
question_type: DNSQuestionType | None = None,
305304
) -> ServiceInfo | None:
306-
"""Returns network's service information for a particular
307-
name and type, or None if no service matches by the timeout,
308-
which defaults to 3 seconds.
309-
310-
:param type_: fully qualified service type name
311-
:param name: the name of the service
312-
:param timeout: milliseconds to wait for a response
313-
:param question_type: The type of questions to ask (DNSQuestionType.QM or DNSQuestionType.QU)
314-
"""
315305
info = ServiceInfo(type_, name)
316306
if info.request(self, timeout, question_type):
317307
return info
@@ -341,17 +331,6 @@ def register_service(
341331
cooperating_responders: bool = False,
342332
strict: bool = True,
343333
) -> None:
344-
"""Registers service information to the network with a default TTL.
345-
Zeroconf will then respond to requests for information for that
346-
service. The name of the service may be changed if needed to make
347-
it unique on the network. Additionally multiple cooperating responders
348-
can register the same service on the network for resilience
349-
(if you want this behavior set `cooperating_responders` to `True`).
350-
351-
While it is not expected during normal operation,
352-
this function may raise EventLoopBlocked if the underlying
353-
call to `register_service` cannot be completed.
354-
"""
355334
assert self.loop is not None
356335
run_coro_with_timeout(
357336
await_awaitable(
@@ -369,12 +348,6 @@ async def async_register_service(
369348
cooperating_responders: bool = False,
370349
strict: bool = True,
371350
) -> Awaitable:
372-
"""Registers service information to the network with a default TTL.
373-
Zeroconf will then respond to requests for information for that
374-
service. The name of the service may be changed if needed to make
375-
it unique on the network. Additionally multiple cooperating responders
376-
can register the same service on the network for resilience
377-
(if you want this behavior set `cooperating_responders` to `True`)."""
378351
if ttl is not None:
379352
# ttl argument is used to maintain backward compatibility
380353
# Setting TTLs via ServiceInfo is preferred
@@ -388,14 +361,6 @@ async def async_register_service(
388361
return asyncio.ensure_future(self._async_broadcast_service(info, _REGISTER_TIME, None))
389362

390363
def update_service(self, info: ServiceInfo) -> None:
391-
"""Registers service information to the network with a default TTL.
392-
Zeroconf will then respond to requests for information for that
393-
service.
394-
395-
While it is not expected during normal operation,
396-
this function may raise EventLoopBlocked if the underlying
397-
call to `async_update_service` cannot be completed.
398-
"""
399364
assert self.loop is not None
400365
run_coro_with_timeout(
401366
await_awaitable(self.async_update_service(info)),
@@ -404,9 +369,6 @@ def update_service(self, info: ServiceInfo) -> None:
404369
)
405370

406371
async def async_update_service(self, info: ServiceInfo) -> Awaitable:
407-
"""Registers service information to the network with a default TTL.
408-
Zeroconf will then respond to requests for information for that
409-
service."""
410372
self.registry.async_update(info)
411373
return asyncio.ensure_future(self._async_broadcast_service(info, _REGISTER_TIME, None))
412374

@@ -502,15 +464,6 @@ async def async_get_service_info(
502464
timeout: int = 3000,
503465
question_type: DNSQuestionType | None = None,
504466
) -> AsyncServiceInfo | None:
505-
"""Returns network's service information for a particular
506-
name and type, or None if no service matches by the timeout,
507-
which defaults to 3 seconds.
508-
509-
:param type_: fully qualified service type name
510-
:param name: the name of the service
511-
:param timeout: milliseconds to wait for a response
512-
:param question_type: The type of questions to ask (DNSQuestionType.QM or DNSQuestionType.QU)
513-
"""
514467
info = AsyncServiceInfo(type_, name)
515468
if await info.async_request(self, timeout, question_type):
516469
return info

‎src/zeroconf/_dns.py‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ def __repr__(self) -> str:
158158

159159

160160
class DNSRecord(DNSEntry): # noqa: PLW1641
161-
"""A DNS record - like a DNS entry, but has a TTL"""
162-
163161
__slots__ = ("created", "ttl")
164162

165163
def __init__(
@@ -203,12 +201,10 @@ def get_expiration_time(self, percent: _int) -> float:
203201

204202
# TODO: Switch to just int here
205203
def get_remaining_ttl(self, now: _float) -> int | float:
206-
"""Returns the remaining TTL in seconds."""
207204
remain = (self.created + (_EXPIRE_FULL_TIME_MS * self.ttl) - now) / 1000.0
208205
return 0 if remain < 0 else remain
209206

210207
def is_expired(self, now: _float) -> bool:
211-
"""Returns true if this record has expired."""
212208
return self.created + (_EXPIRE_FULL_TIME_MS * self.ttl) <= now
213209

214210
def is_stale(self, now: _float) -> bool:
@@ -322,16 +318,13 @@ def _fast_init(
322318
self._hash = hash((self.key, type_, self.class_, cpu, os))
323319

324320
def write(self, out: DNSOutgoing) -> None:
325-
"""Used in constructing an outgoing packet"""
326321
out.write_character_string(self.cpu.encode("utf-8"))
327322
out.write_character_string(self.os.encode("utf-8"))
328323

329324
def __eq__(self, other: Any) -> bool:
330-
"""Tests equality on cpu and os."""
331325
return isinstance(other, DNSHinfo) and self._eq(other)
332326

333327
def _eq(self, other: DNSHinfo) -> bool:
334-
"""Tests equality on cpu and os."""
335328
return self.cpu == other.cpu and self.os == other.os and self._dns_entry_matches(other)
336329

337330
def __hash__(self) -> int:
@@ -490,7 +483,6 @@ def __eq__(self, other: Any) -> bool:
490483
return isinstance(other, DNSService) and self._eq(other)
491484

492485
def _eq(self, other: DNSService) -> bool:
493-
"""Tests equality on priority, weight, port and server."""
494486
return (
495487
self.priority == other.priority
496488
and self.weight == other.weight
@@ -541,7 +533,6 @@ def _fast_init(
541533
self._hash = hash((self.key, type_, self.class_, next_name, *self.rdtypes))
542534

543535
def write(self, out: DNSOutgoing) -> None:
544-
"""Used in constructing an outgoing packet."""
545536
bitmap = bytearray(b"\0" * 32)
546537
total_octets = 0
547538
for rdtype in self.rdtypes:
@@ -613,8 +604,6 @@ def _get_lookup(self) -> dict[DNSRecord, DNSRecord]:
613604
return self._lookup
614605

615606
def suppresses(self, record: _DNSRecord) -> bool:
616-
"""Returns true if any answer in the rrset can suffice for the
617-
information held in this record."""
618607
lookup = self._get_lookup()
619608
other = lookup.get(record)
620609
if other is None:

0 commit comments

Comments
 (0)