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

chore: regenerate the incoming field order and retire remaining 2009 fingerprints by bdraco · Pull Request #1894 · python-zeroconf/python-zeroconf · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .toml  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 0 additions & 1 deletion pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ good-names = [
"t",
"wr",
"zc",
"_GLOBAL_DONE",
]

[tool.pylint."MESSAGES CONTROL"]
Expand Down
17 changes: 8 additions & 9 deletions src/zeroconf/_dns.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def _class_label(class_: int) -> str:
return _CLASSES.get(class_, f"unknown-class-{class_}")


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

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

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

@staticmethod
def get_class_(class_: int) -> str:
Expand Down Expand Up @@ -221,8 +220,8 @@ def suppressed_by(self, msg: DNSIncoming) -> bool:
return False

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

def write(self, out: DNSOutgoing) -> None:
raise AbstractMethodException(f"{type(self).__name__} is missing write")
Expand Down
25 changes: 13 additions & 12 deletions src/zeroconf/_protocol/incoming.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,29 @@ def __init__(
scope_id: int | None = None,
now: float | None = None,
) -> None:
self.data = data
self.flags = 0
self.id = 0
self.now = now or current_time_millis()
self.offset = 0
self.data = data
self.scope_id = scope_id
self.source = source
self.valid = False

self._answers: list[DNSRecord] = []
# Borrowed pointer into `data`; every read and slice must be
# preceded by an explicit bounds check against _data_len.
self._buf = data
self._data_len = len(data)
self._did_read_others = False
self._has_qu_question = False
self._name_cache: dict[int, list[str]] = {}
self._name_str_cache: dict[int, str] = {}
self._questions: list[DNSQuestion] = []
self._answers: list[DNSRecord] = []
self.id = 0
self._num_questions = 0
self._num_additionals = 0
self._num_answers = 0
self._num_authorities = 0
self._num_additionals = 0
self.valid = False
self._did_read_others = False
self.now = now or current_time_millis()
self.source = source
self.scope_id = scope_id
self._has_qu_question = False
self._num_questions = 0
self._questions: list[DNSQuestion] = []
try:
self._initial_parse()
except DECODE_EXCEPTIONS:
Expand Down
2 changes: 1 addition & 1 deletion tests/services/test_browser.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _mock_get_expiration_time(self, percent):
if percent == const._EXPIRE_REFRESH_TIME_PERCENT:
called_with_refresh_time_check = True
return 0
return self.created + (percent * self.ttl * 10)
return self.created + percent * self.ttl * 10

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

Back | FazBrowse Home | New Git URL