]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
misc type annotation lint
authorBob Halley <halley@dnspython.org>
Tue, 8 Mar 2022 19:43:41 +0000 (11:43 -0800)
committerBob Halley <halley@dnspython.org>
Tue, 8 Mar 2022 19:43:41 +0000 (11:43 -0800)
dns/entropy.py
dns/exception.py
dns/message.py
dns/name.py
dns/set.py

index 528a628bf7d6f2750991579d3b7e060eb863774e..b5d34971ef4d0f726f036223f5760f4b6224ec85 100644 (file)
@@ -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
index 941c7a5f966a7a577a358ce2a65b2134d05c52e4..aa0144d423837c5563a3954b57a93b23798d7dea 100644 (file)
@@ -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 <someobj> to list of str(<someobj>)
index ec429fdcdbe35b9ff013c3878630a71e712274cd..7c92cdaf8c34a1728bced497ce5a1927ff49692d 100644 (file)
@@ -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):
index 04fa27283fbfaa853d2f8d1f55febb7cde481eb2..334f2b18688ae0b9d89aff4751927b3e38c39e2d 100644 (file)
@@ -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.
 
index faf968fa1b9591f65f0539f54b81436f69868cbf..a4e12b6773740a27585f96822437b2d8fedf1ea9 100644 (file)
@@ -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)