chore: add typing, enable additional mypy checks (#1514) · python-zeroconf/python-zeroconf@e429d66

@@ -79,7 +79,7 @@ def _fast_init_entry(self, name: str, type_: _int, class_: _int) -> None:

7979

self.class_ = class_ & _CLASS_MASK

8080

self.unique = (class_ & _CLASS_UNIQUE) != 0

818182-

def _dns_entry_matches(self, other) -> bool: # type: ignore[no-untyped-def]

82+

def _dns_entry_matches(self, other: DNSEntry) -> bool:

8383

return self.key == other.key and self.type == other.type and self.class_ == other.class_

84848585

def __eq__(self, other: Any) -> bool:

@@ -135,7 +135,7 @@ def __eq__(self, other: Any) -> bool:

135135

@property

136136

def max_size(self) -> int:

137137

"""Maximum size of the question in the packet."""

138-

return len(self.name.encode("utf-8")) + _LEN_BYTE + _LEN_SHORT + _LEN_SHORT # type # class

138+

return len(self.name.encode("utf-8")) + _LEN_BYTE + _LEN_SHORT + _LEN_SHORT

139139140140

@property

141141

def unicast(self) -> bool:

@@ -199,7 +199,7 @@ def suppressed_by(self, msg: DNSIncoming) -> bool:

199199

return True

200200

return False

201201202-

def _suppressed_by_answer(self, other) -> bool: # type: ignore[no-untyped-def]

202+

def _suppressed_by_answer(self, other: DNSRecord) -> bool:

203203

"""Returns true if another record has same name, type and class,

204204

and if its TTL is at least half of this record's."""

205205

return self == other and other.ttl > (self.ttl / 2)

@@ -285,7 +285,7 @@ def __eq__(self, other: Any) -> bool:

285285

"""Tests equality on address"""

286286

return isinstance(other, DNSAddress) and self._eq(other)

287287288-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

288+

def _eq(self, other: DNSAddress) -> bool:

289289

return (

290290

self.address == other.address

291291

and self.scope_id == other.scope_id

@@ -344,7 +344,7 @@ def __eq__(self, other: Any) -> bool:

344344

"""Tests equality on cpu and os."""

345345

return isinstance(other, DNSHinfo) and self._eq(other)

346346347-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

347+

def _eq(self, other: DNSHinfo) -> bool:

348348

"""Tests equality on cpu and os."""

349349

return self.cpu == other.cpu and self.os == other.os and self._dns_entry_matches(other)

350350

@@ -399,7 +399,7 @@ def __eq__(self, other: Any) -> bool:

399399

"""Tests equality on alias."""

400400

return isinstance(other, DNSPointer) and self._eq(other)

401401402-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

402+

def _eq(self, other: DNSPointer) -> bool:

403403

"""Tests equality on alias."""

404404

return self.alias_key == other.alias_key and self._dns_entry_matches(other)

405405

@@ -447,7 +447,7 @@ def __eq__(self, other: Any) -> bool:

447447

"""Tests equality on text."""

448448

return isinstance(other, DNSText) and self._eq(other)

449449450-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

450+

def _eq(self, other: DNSText) -> bool:

451451

"""Tests equality on text."""

452452

return self.text == other.text and self._dns_entry_matches(other)

453453

@@ -510,7 +510,7 @@ def __eq__(self, other: Any) -> bool:

510510

"""Tests equality on priority, weight, port and server"""

511511

return isinstance(other, DNSService) and self._eq(other)

512512513-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

513+

def _eq(self, other: DNSService) -> bool:

514514

"""Tests equality on priority, weight, port and server."""

515515

return (

516516

self.priority == other.priority

@@ -585,7 +585,7 @@ def __eq__(self, other: Any) -> bool:

585585

"""Tests equality on next_name and rdtypes."""

586586

return isinstance(other, DNSNsec) and self._eq(other)

587587588-

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

588+

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

589589

"""Tests equality on next_name and rdtypes."""

590590

return (

591591

self.next_name == other.next_name