Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rthalley committed Sep 21, 2024
1 parent 36dafb2 commit 2b763dc
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 11 deletions.
4 changes: 3 additions & 1 deletion dns/asyncquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions dns/dnssec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions dns/dnssecalgs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion dns/dnssecalgs/dsa.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import struct
from typing import Optional

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
Expand Down
2 changes: 0 additions & 2 deletions dns/dnssecalgs/ecdsa.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dns/dnssecalgs/eddsa.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion dns/dnssecalgs/rsa.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions dns/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion dns/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion dns/rdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion dns/rdtypes/ANY/GPOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion dns/rdtypes/ANY/ISDN.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"'

Expand Down
5 changes: 4 additions & 1 deletion dns/rdtypes/ANY/LOC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions dns/win32util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2b763dc

Please sign in to comment.