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
"""
-from typing import Optional, Set
+from typing import Any, Dict, Optional, Set
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>)
"""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)
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):
"""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.
(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
"""
if hasattr(self, '_clone_class'):
- cls = self._clone_class
+ cls = self._clone_class # type: ignore
else:
cls = self.__class__
obj = cls.__new__(cls)