Skip to content

Commit 1ca9b3d

Browse files
committed
use the generic type checker ignore syntax instead of pyright
1 parent 8f299d7 commit 1ca9b3d

34 files changed

+110
-118
lines changed

dns/_asyncio_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async def getpeercert(self, timeout):
131131
import httpx
132132

133133
_CoreAsyncNetworkBackend = httpcore.AsyncNetworkBackend
134-
_CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream # pyright: ignore
134+
_CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream # type: ignore
135135

136136
from dns.query import _compute_times, _expiration_for_this_attempt, _remaining
137137

@@ -234,7 +234,7 @@ async def make_socket(
234234
# proper fix for [#637].
235235
source = (dns.inet.any_for_af(af), 0)
236236
transport, protocol = await loop.create_datagram_endpoint(
237-
_DatagramProtocol, # pyright: ignore
237+
_DatagramProtocol, # type: ignore
238238
source,
239239
family=af,
240240
proto=proto,

dns/_immutable_ctx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def nf(*args, **kwargs):
4141
finally:
4242
_in__init__.reset(previous)
4343

44-
nf.__signature__ = inspect.signature(f) # pyright: ignore
44+
nf.__signature__ = inspect.signature(f) # type: ignore
4545
return nf
4646

4747

dns/asyncquery.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ async def udp(
223223
dtuple = None
224224
cm = await backend.make_socket(af, socket.SOCK_DGRAM, 0, stuple, dtuple)
225225
async with cm as s:
226-
await send_udp(s, wire, destination, expiration) # pyright: ignore
226+
await send_udp(s, wire, destination, expiration) # type: ignore
227227
(r, received_time, _) = await receive_udp(
228-
s, # pyright: ignore
228+
s, # type: ignore
229229
destination,
230230
expiration,
231231
ignore_unexpected,
@@ -428,9 +428,9 @@ async def tcp(
428428
af, socket.SOCK_STREAM, 0, stuple, dtuple, timeout
429429
)
430430
async with cm as s:
431-
await send_tcp(s, wire, expiration) # pyright: ignore
431+
await send_tcp(s, wire, expiration) # type: ignore
432432
(r, received_time) = await receive_tcp(
433-
s, # pyright: ignore
433+
s, # type: ignore
434434
expiration,
435435
one_rr_per_rrset,
436436
q.keyring,
@@ -514,8 +514,8 @@ async def tls(
514514

515515

516516
def _maybe_get_resolver(
517-
resolver: Optional["dns.asyncresolver.Resolver"], # pyright: ignore
518-
) -> "dns.asyncresolver.Resolver": # pyright: ignore
517+
resolver: Optional["dns.asyncresolver.Resolver"], # type: ignore
518+
) -> "dns.asyncresolver.Resolver": # type: ignore
519519
# We need a separate method for this to avoid overriding the global
520520
# variable "dns" with the as-yet undefined local variable "dns"
521521
# in https().
@@ -541,7 +541,7 @@ async def https(
541541
post: bool = True,
542542
verify: bool | str | ssl.SSLContext = True,
543543
bootstrap_address: str | None = None,
544-
resolver: Optional["dns.asyncresolver.Resolver"] = None, # pyright: ignore
544+
resolver: Optional["dns.asyncresolver.Resolver"] = None, # type: ignore
545545
family: int = socket.AF_UNSPEC,
546546
http_version: HTTPVersion = HTTPVersion.DEFAULT,
547547
) -> dns.message.Message:
@@ -586,14 +586,14 @@ async def https(
586586
):
587587
if bootstrap_address is None:
588588
resolver = _maybe_get_resolver(resolver)
589-
assert parsed.hostname is not None # pyright: ignore
590-
answers = await resolver.resolve_name( # pyright: ignore
591-
parsed.hostname, family # pyright: ignore
589+
assert parsed.hostname is not None # type: ignore
590+
answers = await resolver.resolve_name( # type: ignore
591+
parsed.hostname, family # type: ignore
592592
)
593593
bootstrap_address = random.choice(list(answers.addresses()))
594594
if client and not isinstance(
595595
client, dns.quic.AsyncQuicConnection
596-
): # pyright: ignore
596+
): # type: ignore
597597
raise ValueError("client parameter must be a dns.quic.AsyncQuicConnection.")
598598
assert client is None or isinstance(client, dns.quic.AsyncQuicConnection)
599599
return await _http3(
@@ -614,7 +614,7 @@ async def https(
614614
if not have_doh:
615615
raise NoDOH # pragma: no cover
616616
# pylint: disable=possibly-used-before-assignment
617-
if client and not isinstance(client, httpx.AsyncClient): # pyright: ignore
617+
if client and not isinstance(client, httpx.AsyncClient): # type: ignore
618618
raise ValueError("client parameter must be an httpx.AsyncClient")
619619
# pylint: enable=possibly-used-before-assignment
620620

@@ -647,7 +647,7 @@ async def https(
647647
family=family,
648648
)
649649

650-
cm = httpx.AsyncClient( # pyright: ignore
650+
cm = httpx.AsyncClient( # type: ignore
651651
http1=h1, http2=h2, verify=verify, transport=transport # type: ignore
652652
)
653653

@@ -662,7 +662,7 @@ async def https(
662662
}
663663
)
664664
response = await backend.wait_for(
665-
the_client.post( # pyright: ignore
665+
the_client.post( # type: ignore
666666
url,
667667
headers=headers,
668668
content=wire,
@@ -674,7 +674,7 @@ async def https(
674674
wire = base64.urlsafe_b64encode(wire).rstrip(b"=")
675675
twire = wire.decode() # httpx does a repr() if we give it bytes
676676
response = await backend.wait_for(
677-
the_client.get( # pyright: ignore
677+
the_client.get( # type: ignore
678678
url,
679679
headers=headers,
680680
params={"dns": twire},
@@ -743,11 +743,11 @@ async def _http3(
743743
if connection:
744744
the_connection = connection
745745
else:
746-
the_connection = the_manager.connect( # pyright: ignore
746+
the_connection = the_manager.connect( # type: ignore
747747
where, port, source, source_port
748748
)
749749
(start, expiration) = _compute_times(timeout)
750-
stream = await the_connection.make_stream(timeout) # pyright: ignore
750+
stream = await the_connection.make_stream(timeout) # type: ignore
751751
async with stream:
752752
# note that send_h3() does not need await
753753
stream.send_h3(url, wire, post)
@@ -815,11 +815,11 @@ async def quic(
815815
server_name=server_hostname,
816816
) as the_manager:
817817
if not connection:
818-
the_connection = the_manager.connect( # pyright: ignore
818+
the_connection = the_manager.connect( # type: ignore
819819
where, port, source, source_port
820820
)
821821
(start, expiration) = _compute_times(timeout)
822-
stream = await the_connection.make_stream(timeout) # pyright: ignore
822+
stream = await the_connection.make_stream(timeout) # type: ignore
823823
async with stream:
824824
await stream.send(wire, True)
825825
wire = await stream.receive(_remaining(expiration))
@@ -870,11 +870,11 @@ async def _inbound_xfr(
870870
mexpiration = expiration
871871
if is_udp:
872872
timeout = _timeout(mexpiration)
873-
(rwire, _) = await udp_sock.recvfrom(65535, timeout) # pyright: ignore
873+
(rwire, _) = await udp_sock.recvfrom(65535, timeout) # type: ignore
874874
else:
875-
ldata = await _read_exactly(tcp_sock, 2, mexpiration) # pyright: ignore
875+
ldata = await _read_exactly(tcp_sock, 2, mexpiration) # type: ignore
876876
(l,) = struct.unpack("!H", ldata)
877-
rwire = await _read_exactly(tcp_sock, l, mexpiration) # pyright: ignore
877+
rwire = await _read_exactly(tcp_sock, l, mexpiration) # type: ignore
878878
r = dns.message.from_wire(
879879
rwire,
880880
keyring=query.keyring,
@@ -929,13 +929,13 @@ async def inbound_xfr(
929929
)
930930
async with s:
931931
try:
932-
async for _ in _inbound_xfr( # pyright: ignore
932+
async for _ in _inbound_xfr( # type: ignore
933933
txn_manager,
934934
s,
935935
query,
936936
serial,
937937
timeout,
938-
expiration, # pyright: ignore
938+
expiration, # type: ignore
939939
):
940940
pass
941941
return
@@ -947,7 +947,7 @@ async def inbound_xfr(
947947
af, socket.SOCK_STREAM, 0, stuple, dtuple, _timeout(expiration)
948948
)
949949
async with s:
950-
async for _ in _inbound_xfr( # pyright: ignore
951-
txn_manager, s, query, serial, timeout, expiration # pyright: ignore
950+
async for _ in _inbound_xfr( # type: ignore
951+
txn_manager, s, query, serial, timeout, expiration # type: ignore
952952
):
953953
pass

dns/dnssecalgs/cryptography.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def to_pem(self) -> bytes:
3434
class CryptographyPrivateKey(GenericPrivateKey):
3535
key: Any = None
3636
key_cls: Any = None
37-
public_cls: Type[CryptographyPublicKey] # pyright: ignore
37+
public_cls: Type[CryptographyPublicKey] # type: ignore
3838

3939
def __init__(self, key: Any) -> None: # pylint: disable=super-init-not-called
4040
if self.key_cls is None:

dns/dnssecalgs/dsa.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def sign(
7878
public_dsa_key = self.key.public_key()
7979
if public_dsa_key.key_size > 1024:
8080
raise ValueError("DSA key size overflow")
81-
der_signature = self.key.sign(
82-
data, self.public_cls.chosen_hash # pyright: ignore
83-
)
81+
der_signature = self.key.sign(data, self.public_cls.chosen_hash) # type: ignore
8482
dsa_r, dsa_s = utils.decode_dss_signature(der_signature)
8583
dsa_t = (public_dsa_key.key_size // 8 - 64) // 8
8684
octets = 20

dns/dnssecalgs/ecdsa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ def sign(
5555
) -> bytes:
5656
"""Sign using a private key per RFC 6605, section 4."""
5757
algorithm = ec.ECDSA(
58-
self.public_cls.chosen_hash, # pyright: ignore
58+
self.public_cls.chosen_hash, # type: ignore
5959
deterministic_signing=deterministic,
6060
)
6161
der_signature = self.key.sign(data, algorithm)
6262
dsa_r, dsa_s = utils.decode_dss_signature(der_signature)
6363
signature = int.to_bytes(
64-
dsa_r, length=self.public_cls.octets, byteorder="big" # pyright: ignore
64+
dsa_r, length=self.public_cls.octets, byteorder="big" # type: ignore
6565
) + int.to_bytes(
66-
dsa_s, length=self.public_cls.octets, byteorder="big" # pyright: ignore
66+
dsa_s, length=self.public_cls.octets, byteorder="big" # type: ignore
6767
)
6868
if verify:
6969
self.public_key().verify(signature, data)
@@ -73,7 +73,7 @@ def sign(
7373
def generate(cls) -> "PrivateECDSA":
7474
return cls(
7575
key=ec.generate_private_key(
76-
curve=cls.public_cls.curve, backend=default_backend() # pyright: ignore
76+
curve=cls.public_cls.curve, backend=default_backend() # type: ignore
7777
),
7878
)
7979

dns/dnssecalgs/eddsa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def from_dnskey(cls, key: DNSKEY) -> "PublicEDDSA":
2727

2828

2929
class PrivateEDDSA(CryptographyPrivateKey):
30-
public_cls: Type[PublicEDDSA] # pyright: ignore
30+
public_cls: Type[PublicEDDSA] # type: ignore
3131

3232
def sign(
3333
self,

dns/dnssecalgs/rsa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def sign(
6464
) -> bytes:
6565
"""Sign using a private key per RFC 3110, section 3."""
6666
signature = self.key.sign(
67-
data, padding.PKCS1v15(), self.public_cls.chosen_hash # pyright: ignore
67+
data, padding.PKCS1v15(), self.public_cls.chosen_hash # type: ignore
6868
)
6969
if verify:
7070
self.public_key().verify(signature, data)

dns/enum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class IntEnum(enum.IntEnum):
2525
@classmethod
2626
def _missing_(cls, value):
2727
cls._check_value(value)
28-
val = int.__new__(cls, value) # pyright: ignore
28+
val = int.__new__(cls, value) # type: ignore
2929
val._name_ = cls._extra_to_text(value, None) or f"{cls._prefix()}{value}"
30-
val._value_ = value # pyright: ignore
30+
val._value_ = value # type: ignore
3131
return val
3232

3333
@classmethod

dns/message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ def _message_factory_from_opcode(opcode):
11031103
return QueryMessage
11041104
elif opcode == dns.opcode.UPDATE:
11051105
_maybe_import_update()
1106-
return dns.update.UpdateMessage # pyright: ignore
1106+
return dns.update.UpdateMessage # type: ignore
11071107
else:
11081108
return Message
11091109

@@ -1207,7 +1207,7 @@ def _get_section(self, section_number, count):
12071207
else:
12081208
with self.parser.restrict_to(rdlen):
12091209
rd = dns.rdata.from_wire_parser(
1210-
rdclass, # pyright: ignore
1210+
rdclass, # type: ignore
12111211
rdtype,
12121212
self.parser,
12131213
self.message.origin,
@@ -1249,7 +1249,7 @@ def _get_section(self, section_number, count):
12491249
rrset = self.message.find_rrset(
12501250
section,
12511251
name,
1252-
rdclass, # pyright: ignore
1252+
rdclass, # type: ignore
12531253
rdtype,
12541254
covers,
12551255
deleting,

0 commit comments

Comments
 (0)