From: Bob Halley Date: Tue, 8 Mar 2022 19:43:41 +0000 (-0800) Subject: misc type annotation lint X-Git-Tag: v2.3.0rc1~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6811d8f8b3044267994134cb3dcd548fad63ebaa;p=thirdparty%2Fdnspython.git misc type annotation lint --- diff --git a/dns/entropy.py b/dns/entropy.py index 528a628b..b5d34971 100644 --- a/dns/entropy.py +++ b/dns/entropy.py @@ -71,7 +71,7 @@ class EntropyPool: with open('/dev/urandom', 'rb', 0) as r: seed = r.read(16) except Exception: - seed = str(time.time()) + seed = str(time.time()).encode() self.seeded = True self.seed_pid = os.getpid() self.digest = None diff --git a/dns/exception.py b/dns/exception.py index 941c7a5f..aa0144d4 100644 --- a/dns/exception.py +++ b/dns/exception.py @@ -22,7 +22,7 @@ always be subclasses of ``DNSException``. """ -from typing import Optional, Set +from typing import Any, Dict, Optional, Set class DNSException(Exception): @@ -89,7 +89,7 @@ class DNSException(Exception): Resulting dictionary has to have keys necessary for str.format call on fmt class variable. """ - fmtargs = {} + fmtargs: Dict[str, Any] = {} for kw, data in kwargs.items(): if isinstance(data, (list, set)): # convert list of to list of str() diff --git a/dns/message.py b/dns/message.py index ec429fdc..7c92cdaf 100644 --- a/dns/message.py +++ b/dns/message.py @@ -932,7 +932,7 @@ class _WireReader: """Read the next *qcount* records from the wire data and add them to the question section. """ - + assert self.message is not None section = self.message.sections[section_number] for _ in range(qcount): qname = self.parser.get_name(self.message.origin) @@ -953,7 +953,7 @@ class _WireReader: section_number: the section of the message to which to add records count: the number of records to read """ - + assert self.message is not None section = self.message.sections[section_number] force_unique = self.one_rr_per_rrset for i in range(count): diff --git a/dns/name.py b/dns/name.py index 04fa2728..334f2b18 100644 --- a/dns/name.py +++ b/dns/name.py @@ -223,7 +223,7 @@ class IDNA2008Codec(IDNACodec): """IDNA 2008 encoder/decoder. """ - def __init__(self, uts_46=False, transitional=False, + def __init__(self, uts_46: bool=False, transitional=False, allow_pure_ascii=False, strict_decode=False): """Initialize the IDNA 2008 encoder/decoder. diff --git a/dns/set.py b/dns/set.py index faf968fa..a4e12b67 100644 --- a/dns/set.py +++ b/dns/set.py @@ -73,7 +73,7 @@ class Set: (k, _) = self.items.popitem() return k - def _clone(self): + def _clone(self) -> 'Set': """Make a (shallow) copy of the set. There is a 'clone protocol' that subclasses of this class @@ -87,7 +87,7 @@ class Set: """ if hasattr(self, '_clone_class'): - cls = self._clone_class + cls = self._clone_class # type: ignore else: cls = self.__class__ obj = cls.__new__(cls)