]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
lint
authorBob Halley <halley@dnspython.org>
Fri, 17 Dec 2021 13:44:23 +0000 (05:44 -0800)
committerBob Halley <halley@dnspython.org>
Fri, 17 Dec 2021 13:44:23 +0000 (05:44 -0800)
dns/asyncquery.py
dns/ipv6.py
dns/rdtypes/ANY/LOC.py
dns/rdtypes/IN/WKS.py
dns/rdtypes/util.py
dns/resolver.py
dns/zone.py
dns/zonefile.py
pylintrc

index 0018541db7dbd7d32e45f43dff9125bf9fc9694b..77936e902316784a3d22cfba3436bdeba95a311b 100644 (file)
@@ -21,7 +21,6 @@ import base64
 import socket
 import struct
 import time
-import urllib
 
 import dns.asyncbackend
 import dns.exception
@@ -33,7 +32,7 @@ import dns.rdataclass
 import dns.rdatatype
 
 from dns.query import _compute_times, _matches_destination, BadResponse, ssl, \
-    UDPMode, have_doh, _have_httpx, _have_http2, NoDOH
+    UDPMode, _have_httpx, _have_http2, NoDOH
 
 if _have_httpx:
     import httpx
index f0e522c0c451c53d08b2f6dd514cc87871e2048a..0db6fcfaa9763e12008b695d05768f26a442e859 100644 (file)
@@ -135,9 +135,9 @@ def inet_aton(text, ignore_scope=False):
     m = _v4_ending.match(text)
     if m is not None:
         b = dns.ipv4.inet_aton(m.group(2))
-        text = (u"{}:{:02x}{:02x}:{:02x}{:02x}".format(m.group(1).decode(),
-                                                       b[0], b[1], b[2],
-                                                       b[3])).encode()
+        text = ("{}:{:02x}{:02x}:{:02x}{:02x}".format(m.group(1).decode(),
+                                                      b[0], b[1], b[2],
+                                                      b[3])).encode()
     #
     # Try to turn '::<whatever>' into ':<whatever>'; if no match try to
     # turn '<whatever>::' into '<whatever>:'
index 1a4ee2bdbbbe9c5c6b6c6dde9718ad62056554f7..c93989947b4a886f75dac84601d2fd518729872d 100644 (file)
@@ -55,7 +55,7 @@ def _float_to_tuple(what):
         what *= -1
     else:
         sign = 1
-    what = round(what * 3600000)  # pylint: disable=round-builtin
+    what = round(what * 3600000)
     degrees = int(what // 3600000)
     what -= degrees * 3600000
     minutes = int(what // 60000)
index e9bc33c511c84178b83387c3b2c8075d6e8adf92..264e45d36b1d47c5cb29ea2c6f7b272493ddfef9 100644 (file)
@@ -47,8 +47,7 @@ class WKS(dns.rdata.Rdata):
 
     def to_text(self, origin=None, relativize=True, **kw):
         bits = []
-        for i in range(0, len(self.bitmap)):
-            byte = self.bitmap[i]
+        for i, byte in enumerate(self.bitmap):
             for j in range(0, 8):
                 if byte & (0x80 >> j):
                     bits.append(str(i * 8 + j))
index 84a2f35b7a8cd50df1a4edd54e71f9524c9d1f9b..9bf8f7e9578acfd59c5416dfd8d2a78088afafe1 100644 (file)
@@ -234,7 +234,7 @@ def parse_formatted_hex(formatted, num_chunks, chunk_size, separator):
     if len(formatted) != num_chunks * (chunk_size + 1) - 1:
         raise ValueError('invalid formatted hex string')
     value = b''
-    for n in range(num_chunks):
+    for _ in range(num_chunks):
         chunk = formatted[0:chunk_size]
         value += int(chunk, 16).to_bytes(chunk_size // 2, 'big')
         formatted = formatted[chunk_size:]
index d42ccab6e509e7b2f4e95647cc715e48190931af..166f84921e7fbb3d996f58755fe96558965b7519 100644 (file)
@@ -1286,20 +1286,20 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None,
             if isinstance(e, dns.resolver.NXDOMAIN):
                 response = e.responses().get(name)
             else:
-                response = e.response()
+                response = e.response()  # pylint: disable=no-value-for-parameter
             if response:
                 for rrs in response.authority:
                     if rrs.rdtype == dns.rdatatype.SOA and \
-                       rrs.rdclass == rdclass:
-                       (nr, _, _) = rrs.name.fullcompare(name)
-                       if nr == dns.name.NAMERELN_SUPERDOMAIN:
-                           # We're doing a proper superdomain check as
-                           # if the name were equal we ought to have gotten
-                           # it in the answer section!  We are ignoring the
-                           # possibility that the authority is insane and
-                           # is including multiple SOA RRs for different
-                           # authorities.
-                           return rrs.name
+                        rrs.rdclass == rdclass:
+                        (nr, _, _) = rrs.name.fullcompare(name)
+                        if nr == dns.name.NAMERELN_SUPERDOMAIN:
+                            # We're doing a proper superdomain check as
+                            # if the name were equal we ought to have gotten
+                            # it in the answer section!  We are ignoring the
+                            # possibility that the authority is insane and
+                            # is including multiple SOA RRs for different
+                            # authorities.
+                            return rrs.name
             # we couldn't extract anything useful from the response (e.g. it's
             # a type 3 NXDOMAIN)
         try:
index dc4274a2f0b663ee6e1c1330036299d35a649c6e..8f98a55f0dea5c80cbb99a8773093473f126054c 100644 (file)
@@ -201,13 +201,13 @@ class Zone(dns.transaction.TransactionManager):
         return self.nodes.__iter__()
 
     def keys(self):
-        return self.nodes.keys()  # pylint: disable=dict-keys-not-iterating
+        return self.nodes.keys()
 
     def values(self):
-        return self.nodes.values()  # pylint: disable=dict-values-not-iterating
+        return self.nodes.values()
 
     def items(self):
-        return self.nodes.items()  # pylint: disable=dict-items-not-iterating
+        return self.nodes.items()
 
     def get(self, key):
         key = self._validate_name(key)
@@ -799,7 +799,7 @@ class Zone(dns.transaction.TransactionManager):
     def _end_write(self, txn):
         pass
 
-    def _commit_version(self, txn, version, origin):
+    def _commit_version(self, _, version, origin):
         self.nodes = version.nodes
         if self.origin is None:
             self.origin = origin
@@ -888,7 +888,7 @@ class Version:
         return node.get_rdataset(self.zone.rdclass, rdtype, covers)
 
     def items(self):
-        return self.nodes.items()  # pylint: disable=dict-items-not-iterating
+        return self.nodes.items()
 
 
 class WritableVersion(Version):
index ce16abb44e788eff4528fd809ac6de3e45f3082f..53b40880bc916c9f0a3ace8c04060a57ded76e7b 100644 (file)
@@ -531,7 +531,7 @@ class RRSetsReaderManager(dns.transaction.TransactionManager):
         self.rrsets = []
 
     def writer(self, replacement=False):
-        assert replacement == True
+        assert replacement is True
         return RRsetsReaderTransaction(self, True, False)
 
     def get_class(self):
@@ -622,4 +622,3 @@ def read_rrsets(text, name=None, ttl=None, rdclass=dns.rdataclass.IN,
                         force_rdtype=rdtype, default_ttl=default_ttl)
         reader.read()
     return manager.rrsets
-
index 493066129f8ced096a8f3b90819e46324e97ca1a..6de0fff781e1161fd8d84bf90e151cb473170c14 100644 (file)
--- a/pylintrc
+++ b/pylintrc
@@ -30,6 +30,8 @@ disable=
     redefined-builtin,
     too-many-lines,
     raise-missing-from,   # we should start doing this, but too noisy for now
+    consider-using-f-string,
+    unspecified-encoding,
 
 [REPORTS]