FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: fresh docstrings for the fuzzy audit sites · python-zeroconf/python-zeroconf@6d58eb4 · GitHub

Repository navigation

Commit 6d58eb4

Browse files
committed
chore: fresh docstrings for the fuzzy audit sites
1 parent 8afd02f commit 6d58eb4

7 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎src/zeroconf/_core.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ def generate_unregister_all_services(self) -> DNSOutgoing | None:
602602
return out
603603

604604
async def async_unregister_all_services(self) -> None:
605+
"""Send goodbye packets for every registered service and drop them all.
606+
607+
Runs only at shutdown, so unlike the single service calls it
608+
returns nothing to await separately.
609+
"""
605610
# Send Goodbye packets https://datatracker.ietf.org/doc/html/rfc6762#section-10.1
606611
out = self.generate_unregister_all_services()
607612
if not out:
@@ -612,6 +617,11 @@ async def async_unregister_all_services(self) -> None:
612617
self.async_send(out)
613618

614619
def unregister_all_services(self) -> None:
620+
"""Send goodbye packets for every registered service and drop them all.
621+
622+
May raise EventLoopBlocked when the event loop cannot finish the
623+
shutdown broadcasts in time.
624+
"""
615625
assert self.loop is not None
616626
run_coro_with_timeout(
617627
self.async_unregister_all_services(),
@@ -700,6 +710,7 @@ def send(
700710
v6_flow_scope: tuple[()] | tuple[int, int] = (),
701711
transport: _WrappedTransport | None = None,
702712
) -> None:
713+
"""Queue a packet for transmission from any thread."""
703714
assert self.loop is not None
704715
self.loop.call_soon_threadsafe(self.async_send, out, addr, port, v6_flow_scope, transport)
705716

@@ -711,6 +722,7 @@ def async_send(
711722
v6_flow_scope: tuple[()] | tuple[int, int] = (),
712723
transport: _WrappedTransport | None = None,
713724
) -> None:
725+
"""Transmit a packet from the event loop."""
714726
if self.done:
715727
return
716728

‎src/zeroconf/_dns.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def _dns_entry_matches(self, other: DNSEntry) -> bool:
8383
return self.key == other.key and self.type == other.type and self.class_ == other.class_
8484

8585
def __eq__(self, other: Any) -> bool:
86+
"""Equal when key, type and class match."""
8687
return isinstance(other, DNSEntry) and self._dns_entry_matches(other)
8788

8889
@staticmethod
@@ -124,6 +125,7 @@ def __hash__(self) -> int:
124125
return self._hash
125126

126127
def __eq__(self, other: Any) -> bool:
128+
"""Equal when the entry fields match a question."""
127129
return isinstance(other, DNSQuestion) and self._dns_entry_matches(other)
128130

129131
@property
@@ -268,6 +270,7 @@ def write(self, out: DNSOutgoing) -> None:
268270
out.write_string(self.address)
269271

270272
def __eq__(self, other: Any) -> bool:
273+
"""Equal when address and the entry fields match."""
271274
return isinstance(other, DNSAddress) and self._eq(other)
272275

273276
def _eq(self, other: DNSAddress) -> bool:
@@ -377,6 +380,7 @@ def write(self, out: DNSOutgoing) -> None:
377380
out.write_name(self.alias)
378381

379382
def __eq__(self, other: Any) -> bool:
383+
"""Equal when alias and the entry fields match."""
380384
return isinstance(other, DNSPointer) and self._eq(other)
381385

382386
def _eq(self, other: DNSPointer) -> bool:
@@ -421,6 +425,7 @@ def __hash__(self) -> int:
421425
return self._hash
422426

423427
def __eq__(self, other: Any) -> bool:
428+
"""Equal when text and the entry fields match."""
424429
return isinstance(other, DNSText) and self._eq(other)
425430

426431
def _eq(self, other: DNSText) -> bool:
@@ -502,6 +507,8 @@ def __repr__(self) -> str:
502507

503508

504509
class DNSNsec(DNSRecord):
510+
"""NSEC record asserting which record types exist for a name."""
511+
505512
__slots__ = ("_hash", "next_name", "rdtypes")
506513

507514
def __init__(
@@ -552,6 +559,7 @@ def write(self, out: DNSOutgoing) -> None:
552559
out.write_string(out_bytes)
553560

554561
def __eq__(self, other: Any) -> bool:
562+
"""Equal when next_name, rdtypes and the entry fields match."""
555563
return isinstance(other, DNSNsec) and self._eq(other)
556564

557565
def _eq(self, other: DNSNsec) -> bool:

‎src/zeroconf/_protocol/incoming.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ def _read_record(
447447
return None
448448

449449
def _read_bitmap(self, end: _int) -> list[int]:
450+
"""Decode the NSEC type bitmap."""
450451
rdtypes = []
451452
if end > self._data_len:
452453
raise IncomingDecodeError(

‎src/zeroconf/_protocol/outgoing.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,41 @@ def add_authorative_answer(self, record: DNSPointer) -> None:
162162
self.authorities.append(record)
163163

164164
def add_additional_answer(self, record: DNSRecord) -> None:
165+
"""Append a record to the additional section per DNS-SD guidance.
166+
167+
From: RFC 6763, DNS-Based Service Discovery, February 2013
168+
169+
12. DNS Additional Record Generation
170+
171+
DNS has an efficiency feature whereby a DNS server may place
172+
additional records in the additional section of the DNS message.
173+
These additional records are records that the client did not
174+
explicitly request, but the server has reasonable grounds to expect
175+
that the client might request them shortly, so including them can
176+
save the client from having to issue additional queries.
177+
178+
This section recommends which additional records SHOULD be generated
179+
to improve network efficiency, for both Unicast and Multicast DNS-SD
180+
responses.
181+
182+
12.1. PTR Records
183+
184+
When including a DNS-SD Service Instance Enumeration or Selective
185+
Instance Enumeration (subtype) PTR record in a response packet, the
186+
server/responder SHOULD include the following additional records:
187+
188+
o The SRV record(s) named in the PTR rdata.
189+
o The TXT record(s) named in the PTR rdata.
190+
o All address records (type "A" and "AAAA") named in the SRV rdata.
191+
192+
12.2. SRV Records
193+
194+
When including an SRV record in a response packet, the
195+
server/responder SHOULD include the following additional records:
196+
197+
o All address records (type "A" and "AAAA") named in the SRV rdata.
198+
199+
"""
165200
self.additionals.append(record)
166201

167202
def _write_byte(self, value: int_) -> None:

‎src/zeroconf/_utils/name.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def service_type_name(type_: str, *, strict: bool = True) -> str: # pylint: dis
4141
"""
4242
Validate a fully qualified service name, instance or subtype. [rfc6763]
4343
44+
Returns the name in its validated, fully qualified form.
45+
4446
Domain names used by mDNS-SD take the following forms:
4547
4648
<sn> . <_tcp|_udp> . local.

‎src/zeroconf/_utils/time.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828

2929

3030
def current_time_millis() -> _float:
31+
"""Monotonic clock reading in milliseconds.
32+
33+
Must stay aligned with asyncio.loop.time(); the backing clock is an
34+
implementation detail and may change.
35+
"""
3136
return time.monotonic() * 1000
3237

3338

‎src/zeroconf/asyncio.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ async def async_register_service(
171171
)
172172

173173
async def async_unregister_all_services(self) -> None:
174+
"""Send goodbye packets for every registered service and drop them all.
175+
176+
Runs only at shutdown, so unlike the single service calls it
177+
returns nothing to await separately.
178+
"""
174179
await self.zeroconf.async_unregister_all_services()
175180

176181
async def async_unregister_service(self, info: ServiceInfo) -> Awaitable:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL