]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
LGTM linting
authorBob Halley <halley@dnspython.org>
Thu, 17 Feb 2022 00:44:33 +0000 (16:44 -0800)
committerBob Halley <halley@dnspython.org>
Thu, 17 Feb 2022 00:44:33 +0000 (16:44 -0800)
dns/_trio_backend.py
dns/query.py
dns/resolver.py
dns/set.py
dns/version.py
dns/xfr.py

index a00d4a4e51ddc36260dc7f4c0ae2a3e519b9f559..4144313a94ea2713ea17978d2e27f18f334ad0d9 100644 (file)
@@ -103,7 +103,6 @@ class Backend(dns._asyncbackend.Backend):
             return DatagramSocket(s)
         elif socktype == socket.SOCK_STREAM:
             stream = trio.SocketStream(s)
-            s = None
             tls = False
             if ssl_context:
                 tls = True
index 6d924b5fe5c25d07c429f5cbd095f2e7d26b08c5..593601d2b44d7b2f25db3c8858870e4a45339ce6 100644 (file)
@@ -76,7 +76,8 @@ except ImportError:  # pragma: no cover
         class SSLSocket:
             pass
 
-        def create_default_context(self, *args, **kwargs):
+        @classmethod
+        def create_default_context(cls, *args, **kwargs):
             raise Exception('no ssl support')
 
 # Function used to create a socket.  Can be overridden if needed in special
index a4b4868e7b86c6c96c00785424a149eab4a36f9b..332c82c0376ae608e8e92383bfc57259bf096da0 100644 (file)
@@ -876,7 +876,7 @@ class BaseResolver:
                 # Time went backwards, but only a little.  This can
                 # happen, e.g. under vmware with older linux kernels.
                 # Pretend it didn't happen.
-                now = start
+                duration = 0
         if duration >= lifetime:
             raise LifetimeTimeout(timeout=duration, errors=errors)
         return min(lifetime - duration, self.timeout)
@@ -1378,7 +1378,10 @@ def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0,
             v6 = _resolver.resolve(host, dns.rdatatype.AAAA,
                                    raise_on_no_answer=False)
             # Note that setting host ensures we query the same name
-            # for A as we did for AAAA.
+            # for A as we did for AAAA.  (This is just in case search lists
+            # are active by default in the resolver configuration and
+            # we might be talking to a server that says NXDOMAIN when it
+            # wants to say NOERROR no data.
             host = v6.qname
             canonical_name = v6.canonical_name.to_text(True)
             if v6.rrset is not None:
@@ -1387,7 +1390,6 @@ def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0,
         if family == socket.AF_INET or family == socket.AF_UNSPEC:
             v4 = _resolver.resolve(host, dns.rdatatype.A,
                                    raise_on_no_answer=False)
-            host = v4.qname
             canonical_name = v4.canonical_name.to_text(True)
             if v4.rrset is not None:
                 for rdata in v4.rrset:
index efa0819a3ea30d0bb5f9412ced4d0720311339f1..ff1ecc503a9a741f9d2a4ca1604cc29c75ab0a72 100644 (file)
@@ -117,7 +117,7 @@ class Set:
 
         if not isinstance(other, Set):
             raise ValueError('other must be a Set instance')
-        if self is other:
+        if self is other:  # lgtm[py/comparison-using-is]
             return
         for item in other.items:
             self.add(item)
@@ -129,7 +129,7 @@ class Set:
 
         if not isinstance(other, Set):
             raise ValueError('other must be a Set instance')
-        if self is other:
+        if self is other:  # lgtm[py/comparison-using-is]
             return
         # we make a copy of the list so that we can remove items from
         # the list without breaking the iterator.
@@ -144,7 +144,7 @@ class Set:
 
         if not isinstance(other, Set):
             raise ValueError('other must be a Set instance')
-        if self is other:
+        if self is other:  # lgtm[py/comparison-using-is]
             self.items.clear()
         else:
             for item in other.items:
@@ -155,7 +155,7 @@ class Set:
 
         if not isinstance(other, Set):
             raise ValueError('other must be a Set instance')
-        if self is other:
+        if self is other:  # lgtm[py/comparison-using-is]
             self.items.clear()
         else:
             overlap = self.intersection(other)
index 55ec7f54cebda32af380ba28e6aab0fcf51c8bd9..be7df4e03346e3fc434066ad3dfa4c1a85eb9973 100644 (file)
@@ -30,16 +30,17 @@ SERIAL = 0
 
 if RELEASELEVEL == 0x0f:  # pragma: no cover
     #: version
-    version = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
+    version = '%d.%d.%d' % \
+        (MAJOR, MINOR, MICRO)  # lgtm[py/unreachable-statement]
 elif RELEASELEVEL == 0x00:  # pragma: no cover
     version = '%d.%d.%ddev%d' % \
-              (MAJOR, MINOR, MICRO, SERIAL)
+              (MAJOR, MINOR, MICRO, SERIAL)  # lgtm[py/unreachable-statement]
 elif RELEASELEVEL == 0x0c:  # pragma: no cover
     version = '%d.%d.%drc%d' % \
-              (MAJOR, MINOR, MICRO, SERIAL)
+              (MAJOR, MINOR, MICRO, SERIAL)  # lgtm[py/unreachable-statement]
 else:  # pragma: no cover
     version = '%d.%d.%d%x%d' % \
-              (MAJOR, MINOR, MICRO, RELEASELEVEL, SERIAL)
+              (MAJOR, MINOR, MICRO, RELEASELEVEL, SERIAL)  # lgtm[py/unreachable-statement]
 
 #: hexversion
 hexversion = MAJOR << 24 | MINOR << 16 | MICRO << 8 | RELEASELEVEL << 4 | \
index cf9a163ead9f9abbe13d482922f6a9825f83a12d..2ef1b0a713be6f3aae4065bfa08103820ef445fa 100644 (file)
@@ -110,7 +110,6 @@ class Inbound:
                 raise dns.exception.FormError("No answer or RRset not "
                                               "for zone origin")
             rrset = message.answer[0]
-            name = rrset.name
             rdataset = rrset
             if rdataset.rdtype != dns.rdatatype.SOA:
                 raise dns.exception.FormError("first RRset is not an SOA")