Skip to content

Commit d3213d7

Browse files
authored
chore: use a constant for address record types (#1149)
1 parent 344fdd1 commit d3213d7

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/zeroconf/_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from ._updates import RecordUpdate, RecordUpdateListener
4848
from ._utils.time import current_time_millis, millis_to_seconds
4949
from .const import (
50+
_ADDRESS_RECORD_TYPES,
5051
_CLASS_IN,
5152
_CLASS_UNIQUE,
5253
_DNS_OTHER_TTL,
@@ -71,7 +72,6 @@
7172
_AnswerWithAdditionalsType = Dict[DNSRecord, Set[DNSRecord]]
7273

7374
_MULTICAST_DELAY_RANDOM_INTERVAL = (20, 120)
74-
_ADDRESS_RECORD_TYPES = {_TYPE_A, _TYPE_AAAA}
7575
_RESPOND_IMMEDIATE_TYPES = {_TYPE_NSEC, _TYPE_SRV, *_ADDRESS_RECORD_TYPES}
7676

7777

src/zeroconf/_services/browser.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from .._utils.name import cached_possible_types, service_type_name
5454
from .._utils.time import current_time_millis, millis_to_seconds
5555
from ..const import (
56+
_ADDRESS_RECORD_TYPES,
5657
_BROWSER_BACKOFF_LIMIT,
5758
_BROWSER_TIME,
5859
_CLASS_IN,
@@ -63,8 +64,6 @@
6364
_MDNS_ADDR,
6465
_MDNS_ADDR6,
6566
_MDNS_PORT,
66-
_TYPE_A,
67-
_TYPE_AAAA,
6867
_TYPE_PTR,
6968
)
7069

@@ -385,7 +384,7 @@ def _async_process_record_update(
385384
if old_record or record.is_expired(now):
386385
return
387386

388-
if record_type in (_TYPE_A, _TYPE_AAAA):
387+
if record_type in _ADDRESS_RECORD_TYPES:
389388
# Iterate through the DNSCache and callback any services that use this address
390389
for type_, name in self._names_matching_types(
391390
{service.name for service in self.zc.cache.async_entries_with_server(record.name)}

src/zeroconf/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@
139139
_TYPE_NSEC: "nsec",
140140
}
141141

142+
_ADDRESS_RECORD_TYPES = {_TYPE_A, _TYPE_AAAA}
143+
142144
_HAS_A_TO_Z = re.compile(r'[A-Za-z]')
143145
_HAS_ONLY_A_TO_Z_NUM_HYPHEN = re.compile(r'^[A-Za-z0-9\-]+$')
144146
_HAS_ONLY_A_TO_Z_NUM_HYPHEN_UNDERSCORE = re.compile(r'^[A-Za-z0-9\-\_]+$')

0 commit comments

Comments
 (0)