From 2b763dc130b400cfa7b01c74cfd72e3c5a1554d4 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sat, 21 Sep 2024 09:37:02 -0700 Subject: [PATCH] linting --- dns/asyncquery.py | 4 +++- dns/dnssec.py | 4 ++++ dns/dnssecalgs/__init__.py | 1 + dns/dnssecalgs/dsa.py | 1 - dns/dnssecalgs/ecdsa.py | 2 -- dns/dnssecalgs/eddsa.py | 2 +- dns/dnssecalgs/rsa.py | 1 - dns/name.py | 1 + dns/query.py | 3 ++- dns/rdataset.py | 3 ++- dns/rdtypes/ANY/GPOS.py | 5 ++++- dns/rdtypes/ANY/ISDN.py | 5 ++++- dns/rdtypes/ANY/LOC.py | 5 ++++- dns/win32util.py | 1 + 14 files changed, 27 insertions(+), 11 deletions(-) diff --git a/dns/asyncquery.py b/dns/asyncquery.py index ce885a4c..e89f836b 100644 --- a/dns/asyncquery.py +++ b/dns/asyncquery.py @@ -562,6 +562,7 @@ async def https( extensions = {} if bootstrap_address is None: + # pylint: disable=possibly-used-before-assignment parsed = urllib.parse.urlparse(url) if parsed.hostname is None: raise ValueError("no hostname in URL") @@ -595,8 +596,10 @@ async def https( if not have_doh: raise NoDOH # pragma: no cover + # pylint: disable=possibly-used-before-assignment if client and not isinstance(client, httpx.AsyncClient): raise ValueError("session parameter must be an httpx.AsyncClient") + # pylint: enable=possibly-used-before-assignment wire = q.to_wire() headers = {"accept": "application/dns-message"} @@ -899,7 +902,6 @@ async def inbound_xfr( except dns.xfr.UseTCP: if udp_mode == UDPMode.ONLY: raise - pass s = await backend.make_socket( af, socket.SOCK_STREAM, 0, stuple, dtuple, _timeout(expiration) diff --git a/dns/dnssec.py b/dns/dnssec.py index 77edb202..b69d0a12 100644 --- a/dns/dnssec.py +++ b/dns/dnssec.py @@ -325,6 +325,7 @@ def _get_rrname_rdataset( def _validate_signature(sig: bytes, data: bytes, key: DNSKEY) -> None: + # pylint: disable=possibly-used-before-assignment public_cls = get_algorithm_cls_from_dnskey(key).public_cls try: public_key = public_cls.from_dnskey(key) @@ -389,6 +390,7 @@ def _validate_rrsig( data = _make_rrsig_signature_data(rrset, rrsig, origin) + # pylint: disable=possibly-used-before-assignment for candidate_key in candidate_keys: if not policy.ok_to_validate(candidate_key): continue @@ -587,6 +589,7 @@ def _sign( data = dns.dnssec._make_rrsig_signature_data(rrset, rrsig_template, origin) + # pylint: disable=possibly-used-before-assignment if isinstance(private_key, GenericPrivateKey): signing_key = private_key else: @@ -695,6 +698,7 @@ def _make_dnskey( algorithm = Algorithm.make(algorithm) + # pylint: disable=possibly-used-before-assignment if isinstance(public_key, GenericPublicKey): return public_key.to_dnskey(flags=flags, protocol=protocol) else: diff --git a/dns/dnssecalgs/__init__.py b/dns/dnssecalgs/__init__.py index b017d3e3..602367e3 100644 --- a/dns/dnssecalgs/__init__.py +++ b/dns/dnssecalgs/__init__.py @@ -26,6 +26,7 @@ algorithms: Dict[Tuple[Algorithm, AlgorithmPrefix], Type[GenericPrivateKey]] = {} if _have_cryptography: + # pylint: disable=possibly-used-before-assignment algorithms.update( { (Algorithm.RSAMD5, None): PrivateRSAMD5, diff --git a/dns/dnssecalgs/dsa.py b/dns/dnssecalgs/dsa.py index 1c84f49f..adca3def 100644 --- a/dns/dnssecalgs/dsa.py +++ b/dns/dnssecalgs/dsa.py @@ -1,5 +1,4 @@ import struct -from typing import Optional from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes diff --git a/dns/dnssecalgs/ecdsa.py b/dns/dnssecalgs/ecdsa.py index 6845a039..86d5764c 100644 --- a/dns/dnssecalgs/ecdsa.py +++ b/dns/dnssecalgs/ecdsa.py @@ -1,5 +1,3 @@ -from typing import Optional - from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec, utils diff --git a/dns/dnssecalgs/eddsa.py b/dns/dnssecalgs/eddsa.py index d70923fc..604bcbfe 100644 --- a/dns/dnssecalgs/eddsa.py +++ b/dns/dnssecalgs/eddsa.py @@ -1,4 +1,4 @@ -from typing import Optional, Type +from typing import Type from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ed448, ed25519 diff --git a/dns/dnssecalgs/rsa.py b/dns/dnssecalgs/rsa.py index 935edadc..27537aad 100644 --- a/dns/dnssecalgs/rsa.py +++ b/dns/dnssecalgs/rsa.py @@ -1,6 +1,5 @@ import math import struct -from typing import Optional from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes diff --git a/dns/name.py b/dns/name.py index 39c54744..f79f0d0f 100644 --- a/dns/name.py +++ b/dns/name.py @@ -277,6 +277,7 @@ def encode(self, label: str) -> bytes: raise NoIDNA2008 try: if self.uts_46: + # pylint: disable=possibly-used-before-assignment label = idna.uts46_remap(label, False, self.transitional) return idna.alabel(label) except idna.IDNAError as e: diff --git a/dns/query.py b/dns/query.py index 9060012c..43535945 100644 --- a/dns/query.py +++ b/dns/query.py @@ -451,6 +451,7 @@ def https( extensions = {} if bootstrap_address is None: + # pylint: disable=possibly-used-before-assignment parsed = urllib.parse.urlparse(url) if parsed.hostname is None: raise ValueError("no hostname in URL") @@ -1158,6 +1159,7 @@ def tcp( cm = _make_socket(af, socket.SOCK_STREAM, source) with cm as s: if not sock: + # pylint: disable=possibly-used-before-assignment _connect(s, destination, expiration) send_tcp(s, wire, expiration) (r, received_time) = receive_tcp( @@ -1654,7 +1656,6 @@ def inbound_xfr( except dns.xfr.UseTCP: if udp_mode == UDPMode.ONLY: raise - pass with _make_socket(af, socket.SOCK_STREAM, source) as s: _connect(s, destination, expiration) diff --git a/dns/rdataset.py b/dns/rdataset.py index 52d2481d..39cab236 100644 --- a/dns/rdataset.py +++ b/dns/rdataset.py @@ -248,7 +248,8 @@ def to_text( # (which is meaningless anyway). # s.write( - f"{ntext}{pad}{dns.rdataclass.to_text(rdclass)} {dns.rdatatype.to_text(self.rdtype)}\n" + f"{ntext}{pad}{dns.rdataclass.to_text(rdclass)} " + f"{dns.rdatatype.to_text(self.rdtype)}\n" ) else: for rd in self: diff --git a/dns/rdtypes/ANY/GPOS.py b/dns/rdtypes/ANY/GPOS.py index 0aa33798..d79f4a06 100644 --- a/dns/rdtypes/ANY/GPOS.py +++ b/dns/rdtypes/ANY/GPOS.py @@ -75,7 +75,10 @@ def __init__(self, rdclass, rdtype, latitude, longitude, altitude): raise dns.exception.FormError("bad longitude") def to_text(self, origin=None, relativize=True, **kw): - return f"{self.latitude.decode()} {self.longitude.decode()} {self.altitude.decode()}" + return ( + f"{self.latitude.decode()} {self.longitude.decode()} " + f"{self.altitude.decode()}" + ) @classmethod def from_text( diff --git a/dns/rdtypes/ANY/ISDN.py b/dns/rdtypes/ANY/ISDN.py index ef8166ff..6428a0a8 100644 --- a/dns/rdtypes/ANY/ISDN.py +++ b/dns/rdtypes/ANY/ISDN.py @@ -38,7 +38,10 @@ def __init__(self, rdclass, rdtype, address, subaddress): def to_text(self, origin=None, relativize=True, **kw): if self.subaddress: - return f'"{dns.rdata._escapify(self.address)}" "{dns.rdata._escapify(self.subaddress)}"' + return ( + f'"{dns.rdata._escapify(self.address)}" ' + f'"{dns.rdata._escapify(self.subaddress)}"' + ) else: return f'"{dns.rdata._escapify(self.address)}"' diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py index cf708933..1153cf03 100644 --- a/dns/rdtypes/ANY/LOC.py +++ b/dns/rdtypes/ANY/LOC.py @@ -184,7 +184,10 @@ def to_text(self, origin=None, relativize=True, **kw): or self.horizontal_precision != _default_hprec or self.vertical_precision != _default_vprec ): - text += f" {self.size / 100.0:0.2f}m {self.horizontal_precision / 100.0:0.2f}m {self.vertical_precision / 100.0:0.2f}m" + text += ( + f" {self.size / 100.0:0.2f}m {self.horizontal_precision / 100.0:0.2f}m" + f" {self.vertical_precision / 100.0:0.2f}m" + ) return text @classmethod diff --git a/dns/win32util.py b/dns/win32util.py index 7d8542de..9ed3f11b 100644 --- a/dns/win32util.py +++ b/dns/win32util.py @@ -44,6 +44,7 @@ def __init__(self): if _have_wmi: class _WMIGetter(threading.Thread): + # pylint: disable=possibly-used-before-assignment def __init__(self): super().__init__() self.info = DnsInfo()