Skip to content

Commit b110640

Browse files
authored
chore: regenerate the incoming field order and retire remaining 2009 fingerprints (#1894)
1 parent d5f4102 commit b110640

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ good-names = [
207207
"t",
208208
"wr",
209209
"zc",
210-
"_GLOBAL_DONE",
211210
]
212211

213212
[tool.pylint."MESSAGES CONTROL"]

‎src/zeroconf/_dns.py‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def _class_label(class_: int) -> str:
4444
return _CLASSES.get(class_, f"unknown-class-{class_}")
4545

4646

47-
def _format_display(kind: str, fields: list[tuple[str, str]]) -> str:
47+
def _format_display(kind: str, fields: list[tuple[str, str]], data: bytes | str | None = None) -> str:
48+
if data is not None:
49+
fields = [*fields, ("data", str(data))]
4850
body = " ".join([f"{key}={value}" if key else value for key, value in fields])
4951
return f"<{kind} {body}>"
5052

@@ -83,12 +85,9 @@ def class_label(self) -> str:
8385
"""Human readable label for the record class."""
8486
return _class_label(self.class_)
8587

86-
def entry_to_string(self, hdr: str, other: bytes | str | None) -> str:
87-
"""Compatibility alias rendering through the display formatter."""
88-
fields = self._display_fields()
89-
if other is not None:
90-
fields.append(("data", str(other)))
91-
return _format_display(hdr, fields)
88+
def entry_to_string(self, kind: str, extra: bytes | str | None) -> str:
89+
"""Compatibility alias for the display formatter."""
90+
return _format_display(kind, self._display_fields(), extra)
9291

9392
@staticmethod
9493
def get_class_(class_: int) -> str:
@@ -221,8 +220,8 @@ def suppressed_by(self, msg: DNSIncoming) -> bool:
221220
return False
222221

223222
def to_string(self, other: bytes | str) -> str:
224-
"""Compatibility alias rendering through the display formatter."""
225-
return self._repr_with(("data", str(other)))
223+
"""Compatibility alias for the display formatter."""
224+
return _format_display(type(self).__name__, self._display_fields(), other)
226225

227226
def write(self, out: DNSOutgoing) -> None:
228227
raise AbstractMethodException(f"{type(self).__name__} is missing write")

‎src/zeroconf/_protocol/incoming.py‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,29 @@ def __init__(
8787
scope_id: int | None = None,
8888
now: float | None = None,
8989
) -> None:
90+
self.data = data
9091
self.flags = 0
92+
self.id = 0
93+
self.now = now or current_time_millis()
9194
self.offset = 0
92-
self.data = data
95+
self.scope_id = scope_id
96+
self.source = source
97+
self.valid = False
98+
99+
self._answers: list[DNSRecord] = []
93100
# Borrowed pointer into `data`; every read and slice must be
94101
# preceded by an explicit bounds check against _data_len.
95102
self._buf = data
96103
self._data_len = len(data)
104+
self._did_read_others = False
105+
self._has_qu_question = False
97106
self._name_cache: dict[int, list[str]] = {}
98107
self._name_str_cache: dict[int, str] = {}
99-
self._questions: list[DNSQuestion] = []
100-
self._answers: list[DNSRecord] = []
101-
self.id = 0
102-
self._num_questions = 0
108+
self._num_additionals = 0
103109
self._num_answers = 0
104110
self._num_authorities = 0
105-
self._num_additionals = 0
106-
self.valid = False
107-
self._did_read_others = False
108-
self.now = now or current_time_millis()
109-
self.source = source
110-
self.scope_id = scope_id
111-
self._has_qu_question = False
111+
self._num_questions = 0
112+
self._questions: list[DNSQuestion] = []
112113
try:
113114
self._initial_parse()
114115
except DECODE_EXCEPTIONS:

‎tests/services/test_browser.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def _mock_get_expiration_time(self, percent):
433433
if percent == const._EXPIRE_REFRESH_TIME_PERCENT:
434434
called_with_refresh_time_check = True
435435
return 0
436-
return self.created + (percent * self.ttl * 10)
436+
return self.created + percent * self.ttl * 10
437437

438438
# Set an expire time that will force a refresh
439439
with patch("zeroconf.DNSRecord.get_expiration_time", new=_mock_get_expiration_time):

0 commit comments

Comments
 (0)