From: Bob Halley Date: Thu, 17 Feb 2022 00:44:33 +0000 (-0800) Subject: LGTM linting X-Git-Tag: v2.3.0rc1~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdad6a715c6b9fcd3c91712a08bcd4226e7200eb;p=thirdparty%2Fdnspython.git LGTM linting --- diff --git a/dns/_trio_backend.py b/dns/_trio_backend.py index a00d4a4e..4144313a 100644 --- a/dns/_trio_backend.py +++ b/dns/_trio_backend.py @@ -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 diff --git a/dns/query.py b/dns/query.py index 6d924b5f..593601d2 100644 --- a/dns/query.py +++ b/dns/query.py @@ -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 diff --git a/dns/resolver.py b/dns/resolver.py index a4b4868e..332c82c0 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -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: diff --git a/dns/set.py b/dns/set.py index efa0819a..ff1ecc50 100644 --- a/dns/set.py +++ b/dns/set.py @@ -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) diff --git a/dns/version.py b/dns/version.py index 55ec7f54..be7df4e0 100644 --- a/dns/version.py +++ b/dns/version.py @@ -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 | \ diff --git a/dns/xfr.py b/dns/xfr.py index cf9a163e..2ef1b0a7 100644 --- a/dns/xfr.py +++ b/dns/xfr.py @@ -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")