From 1ca9b3dd27853b14935ded71b5063a450dc7dfc7 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 5 Dec 2025 15:42:14 -0800 Subject: [PATCH] use the generic type checker ignore syntax instead of pyright --- dns/_asyncio_backend.py | 4 +-- dns/_immutable_ctx.py | 2 +- dns/asyncquery.py | 52 +++++++++++++++++----------------- dns/dnssecalgs/cryptography.py | 2 +- dns/dnssecalgs/dsa.py | 4 +-- dns/dnssecalgs/ecdsa.py | 8 +++--- dns/dnssecalgs/eddsa.py | 2 +- dns/dnssecalgs/rsa.py | 2 +- dns/enum.py | 4 +-- dns/message.py | 6 ++-- dns/query.py | 36 +++++++++++------------ dns/quic/__init__.py | 6 ++-- dns/quic/_trio.py | 2 +- dns/rdata.py | 2 +- dns/rdataset.py | 18 ++++++------ dns/rdtypes/ANY/CERT.py | 2 +- dns/rdtypes/ANY/LOC.py | 4 +-- dns/rdtypes/ANY/OPENPGPKEY.py | 2 +- dns/rdtypes/ANY/SSHFP.py | 2 +- dns/rdtypes/ANY/ZONEMD.py | 2 +- dns/rdtypes/IN/DHCID.py | 2 +- dns/rdtypes/IN/IPSECKEY.py | 2 +- dns/rdtypes/dnskeybase.py | 2 +- dns/rdtypes/dsbase.py | 2 +- dns/rdtypes/rrsigbase.py | 4 +-- dns/rdtypes/tlsabase.py | 4 +-- dns/rdtypes/util.py | 6 ++-- dns/renderer.py | 10 +++---- dns/resolver.py | 6 ++-- dns/update.py | 2 +- dns/versioned.py | 4 +-- dns/xfr.py | 2 +- dns/zone.py | 18 ++++++------ dns/zonefile.py | 2 +- 34 files changed, 110 insertions(+), 118 deletions(-) diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index 303908ce..d7ce1467 100644 --- a/dns/_asyncio_backend.py +++ b/dns/_asyncio_backend.py @@ -131,7 +131,7 @@ if dns._features.have("doh"): import httpx _CoreAsyncNetworkBackend = httpcore.AsyncNetworkBackend - _CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream # pyright: ignore + _CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream # type: ignore from dns.query import _compute_times, _expiration_for_this_attempt, _remaining @@ -234,7 +234,7 @@ class Backend(dns._asyncbackend.Backend): # proper fix for [#637]. source = (dns.inet.any_for_af(af), 0) transport, protocol = await loop.create_datagram_endpoint( - _DatagramProtocol, # pyright: ignore + _DatagramProtocol, # type: ignore source, family=af, proto=proto, diff --git a/dns/_immutable_ctx.py b/dns/_immutable_ctx.py index b3d72dee..344bef88 100644 --- a/dns/_immutable_ctx.py +++ b/dns/_immutable_ctx.py @@ -41,7 +41,7 @@ def _immutable_init(f): finally: _in__init__.reset(previous) - nf.__signature__ = inspect.signature(f) # pyright: ignore + nf.__signature__ = inspect.signature(f) # type: ignore return nf diff --git a/dns/asyncquery.py b/dns/asyncquery.py index bb770458..b5e58540 100644 --- a/dns/asyncquery.py +++ b/dns/asyncquery.py @@ -223,9 +223,9 @@ async def udp( dtuple = None cm = await backend.make_socket(af, socket.SOCK_DGRAM, 0, stuple, dtuple) async with cm as s: - await send_udp(s, wire, destination, expiration) # pyright: ignore + await send_udp(s, wire, destination, expiration) # type: ignore (r, received_time, _) = await receive_udp( - s, # pyright: ignore + s, # type: ignore destination, expiration, ignore_unexpected, @@ -428,9 +428,9 @@ async def tcp( af, socket.SOCK_STREAM, 0, stuple, dtuple, timeout ) async with cm as s: - await send_tcp(s, wire, expiration) # pyright: ignore + await send_tcp(s, wire, expiration) # type: ignore (r, received_time) = await receive_tcp( - s, # pyright: ignore + s, # type: ignore expiration, one_rr_per_rrset, q.keyring, @@ -514,8 +514,8 @@ async def tls( def _maybe_get_resolver( - resolver: Optional["dns.asyncresolver.Resolver"], # pyright: ignore -) -> "dns.asyncresolver.Resolver": # pyright: ignore + resolver: Optional["dns.asyncresolver.Resolver"], # type: ignore +) -> "dns.asyncresolver.Resolver": # type: ignore # We need a separate method for this to avoid overriding the global # variable "dns" with the as-yet undefined local variable "dns" # in https(). @@ -541,7 +541,7 @@ async def https( post: bool = True, verify: bool | str | ssl.SSLContext = True, bootstrap_address: str | None = None, - resolver: Optional["dns.asyncresolver.Resolver"] = None, # pyright: ignore + resolver: Optional["dns.asyncresolver.Resolver"] = None, # type: ignore family: int = socket.AF_UNSPEC, http_version: HTTPVersion = HTTPVersion.DEFAULT, ) -> dns.message.Message: @@ -586,14 +586,14 @@ async def https( ): if bootstrap_address is None: resolver = _maybe_get_resolver(resolver) - assert parsed.hostname is not None # pyright: ignore - answers = await resolver.resolve_name( # pyright: ignore - parsed.hostname, family # pyright: ignore + assert parsed.hostname is not None # type: ignore + answers = await resolver.resolve_name( # type: ignore + parsed.hostname, family # type: ignore ) bootstrap_address = random.choice(list(answers.addresses())) if client and not isinstance( client, dns.quic.AsyncQuicConnection - ): # pyright: ignore + ): # type: ignore raise ValueError("client parameter must be a dns.quic.AsyncQuicConnection.") assert client is None or isinstance(client, dns.quic.AsyncQuicConnection) return await _http3( @@ -614,7 +614,7 @@ 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): # pyright: ignore + if client and not isinstance(client, httpx.AsyncClient): # type: ignore raise ValueError("client parameter must be an httpx.AsyncClient") # pylint: enable=possibly-used-before-assignment @@ -647,7 +647,7 @@ async def https( family=family, ) - cm = httpx.AsyncClient( # pyright: ignore + cm = httpx.AsyncClient( # type: ignore http1=h1, http2=h2, verify=verify, transport=transport # type: ignore ) @@ -662,7 +662,7 @@ async def https( } ) response = await backend.wait_for( - the_client.post( # pyright: ignore + the_client.post( # type: ignore url, headers=headers, content=wire, @@ -674,7 +674,7 @@ async def https( wire = base64.urlsafe_b64encode(wire).rstrip(b"=") twire = wire.decode() # httpx does a repr() if we give it bytes response = await backend.wait_for( - the_client.get( # pyright: ignore + the_client.get( # type: ignore url, headers=headers, params={"dns": twire}, @@ -743,11 +743,11 @@ async def _http3( if connection: the_connection = connection else: - the_connection = the_manager.connect( # pyright: ignore + the_connection = the_manager.connect( # type: ignore where, port, source, source_port ) (start, expiration) = _compute_times(timeout) - stream = await the_connection.make_stream(timeout) # pyright: ignore + stream = await the_connection.make_stream(timeout) # type: ignore async with stream: # note that send_h3() does not need await stream.send_h3(url, wire, post) @@ -815,11 +815,11 @@ async def quic( server_name=server_hostname, ) as the_manager: if not connection: - the_connection = the_manager.connect( # pyright: ignore + the_connection = the_manager.connect( # type: ignore where, port, source, source_port ) (start, expiration) = _compute_times(timeout) - stream = await the_connection.make_stream(timeout) # pyright: ignore + stream = await the_connection.make_stream(timeout) # type: ignore async with stream: await stream.send(wire, True) wire = await stream.receive(_remaining(expiration)) @@ -870,11 +870,11 @@ async def _inbound_xfr( mexpiration = expiration if is_udp: timeout = _timeout(mexpiration) - (rwire, _) = await udp_sock.recvfrom(65535, timeout) # pyright: ignore + (rwire, _) = await udp_sock.recvfrom(65535, timeout) # type: ignore else: - ldata = await _read_exactly(tcp_sock, 2, mexpiration) # pyright: ignore + ldata = await _read_exactly(tcp_sock, 2, mexpiration) # type: ignore (l,) = struct.unpack("!H", ldata) - rwire = await _read_exactly(tcp_sock, l, mexpiration) # pyright: ignore + rwire = await _read_exactly(tcp_sock, l, mexpiration) # type: ignore r = dns.message.from_wire( rwire, keyring=query.keyring, @@ -929,13 +929,13 @@ async def inbound_xfr( ) async with s: try: - async for _ in _inbound_xfr( # pyright: ignore + async for _ in _inbound_xfr( # type: ignore txn_manager, s, query, serial, timeout, - expiration, # pyright: ignore + expiration, # type: ignore ): pass return @@ -947,7 +947,7 @@ async def inbound_xfr( af, socket.SOCK_STREAM, 0, stuple, dtuple, _timeout(expiration) ) async with s: - async for _ in _inbound_xfr( # pyright: ignore - txn_manager, s, query, serial, timeout, expiration # pyright: ignore + async for _ in _inbound_xfr( # type: ignore + txn_manager, s, query, serial, timeout, expiration # type: ignore ): pass diff --git a/dns/dnssecalgs/cryptography.py b/dns/dnssecalgs/cryptography.py index a5dde6a4..8d6876e8 100644 --- a/dns/dnssecalgs/cryptography.py +++ b/dns/dnssecalgs/cryptography.py @@ -34,7 +34,7 @@ class CryptographyPublicKey(GenericPublicKey): class CryptographyPrivateKey(GenericPrivateKey): key: Any = None key_cls: Any = None - public_cls: Type[CryptographyPublicKey] # pyright: ignore + public_cls: Type[CryptographyPublicKey] # type: ignore def __init__(self, key: Any) -> None: # pylint: disable=super-init-not-called if self.key_cls is None: diff --git a/dns/dnssecalgs/dsa.py b/dns/dnssecalgs/dsa.py index a4eb9879..0d5517b7 100644 --- a/dns/dnssecalgs/dsa.py +++ b/dns/dnssecalgs/dsa.py @@ -78,9 +78,7 @@ class PrivateDSA(CryptographyPrivateKey): public_dsa_key = self.key.public_key() if public_dsa_key.key_size > 1024: raise ValueError("DSA key size overflow") - der_signature = self.key.sign( - data, self.public_cls.chosen_hash # pyright: ignore - ) + der_signature = self.key.sign(data, self.public_cls.chosen_hash) # type: ignore dsa_r, dsa_s = utils.decode_dss_signature(der_signature) dsa_t = (public_dsa_key.key_size // 8 - 64) // 8 octets = 20 diff --git a/dns/dnssecalgs/ecdsa.py b/dns/dnssecalgs/ecdsa.py index e3f3f061..6684892e 100644 --- a/dns/dnssecalgs/ecdsa.py +++ b/dns/dnssecalgs/ecdsa.py @@ -55,15 +55,15 @@ class PrivateECDSA(CryptographyPrivateKey): ) -> bytes: """Sign using a private key per RFC 6605, section 4.""" algorithm = ec.ECDSA( - self.public_cls.chosen_hash, # pyright: ignore + self.public_cls.chosen_hash, # type: ignore deterministic_signing=deterministic, ) der_signature = self.key.sign(data, algorithm) dsa_r, dsa_s = utils.decode_dss_signature(der_signature) signature = int.to_bytes( - dsa_r, length=self.public_cls.octets, byteorder="big" # pyright: ignore + dsa_r, length=self.public_cls.octets, byteorder="big" # type: ignore ) + int.to_bytes( - dsa_s, length=self.public_cls.octets, byteorder="big" # pyright: ignore + dsa_s, length=self.public_cls.octets, byteorder="big" # type: ignore ) if verify: self.public_key().verify(signature, data) @@ -73,7 +73,7 @@ class PrivateECDSA(CryptographyPrivateKey): def generate(cls) -> "PrivateECDSA": return cls( key=ec.generate_private_key( - curve=cls.public_cls.curve, backend=default_backend() # pyright: ignore + curve=cls.public_cls.curve, backend=default_backend() # type: ignore ), ) diff --git a/dns/dnssecalgs/eddsa.py b/dns/dnssecalgs/eddsa.py index 1cbb4079..361c3dbd 100644 --- a/dns/dnssecalgs/eddsa.py +++ b/dns/dnssecalgs/eddsa.py @@ -27,7 +27,7 @@ class PublicEDDSA(CryptographyPublicKey): class PrivateEDDSA(CryptographyPrivateKey): - public_cls: Type[PublicEDDSA] # pyright: ignore + public_cls: Type[PublicEDDSA] # type: ignore def sign( self, diff --git a/dns/dnssecalgs/rsa.py b/dns/dnssecalgs/rsa.py index de9160bb..43ef7663 100644 --- a/dns/dnssecalgs/rsa.py +++ b/dns/dnssecalgs/rsa.py @@ -64,7 +64,7 @@ class PrivateRSA(CryptographyPrivateKey): ) -> bytes: """Sign using a private key per RFC 3110, section 3.""" signature = self.key.sign( - data, padding.PKCS1v15(), self.public_cls.chosen_hash # pyright: ignore + data, padding.PKCS1v15(), self.public_cls.chosen_hash # type: ignore ) if verify: self.public_key().verify(signature, data) diff --git a/dns/enum.py b/dns/enum.py index 822c9958..44f76afa 100644 --- a/dns/enum.py +++ b/dns/enum.py @@ -25,9 +25,9 @@ class IntEnum(enum.IntEnum): @classmethod def _missing_(cls, value): cls._check_value(value) - val = int.__new__(cls, value) # pyright: ignore + val = int.__new__(cls, value) # type: ignore val._name_ = cls._extra_to_text(value, None) or f"{cls._prefix()}{value}" - val._value_ = value # pyright: ignore + val._value_ = value # type: ignore return val @classmethod diff --git a/dns/message.py b/dns/message.py index 711370d9..82d4d226 100644 --- a/dns/message.py +++ b/dns/message.py @@ -1103,7 +1103,7 @@ def _message_factory_from_opcode(opcode): return QueryMessage elif opcode == dns.opcode.UPDATE: _maybe_import_update() - return dns.update.UpdateMessage # pyright: ignore + return dns.update.UpdateMessage # type: ignore else: return Message @@ -1207,7 +1207,7 @@ class _WireReader: else: with self.parser.restrict_to(rdlen): rd = dns.rdata.from_wire_parser( - rdclass, # pyright: ignore + rdclass, # type: ignore rdtype, self.parser, self.message.origin, @@ -1249,7 +1249,7 @@ class _WireReader: rrset = self.message.find_rrset( section, name, - rdclass, # pyright: ignore + rdclass, # type: ignore rdtype, covers, deleting, diff --git a/dns/query.py b/dns/query.py index 17b1862d..34864d99 100644 --- a/dns/query.py +++ b/dns/query.py @@ -127,7 +127,7 @@ if _have_httpx: ): # pylint: disable=signature-differs raise NotImplementedError - class _HTTPTransport(httpx.HTTPTransport): # pyright: ignore + class _HTTPTransport(httpx.HTTPTransport): # type: ignore def __init__( self, *args, @@ -230,7 +230,7 @@ def _wait_for(fd, readable, writable, _, expiration): if writable: events |= selectors.EVENT_WRITE if events: - sel.register(fd, events) # pyright: ignore + sel.register(fd, events) # type: ignore if expiration is None: timeout = None else: @@ -411,8 +411,8 @@ def _make_socket( def _maybe_get_resolver( - resolver: Optional["dns.resolver.Resolver"], # pyright: ignore -) -> "dns.resolver.Resolver": # pyright: ignore + resolver: Optional["dns.resolver.Resolver"], # type: ignore +) -> "dns.resolver.Resolver": # type: ignore # We need a separate method for this to avoid overriding the global # variable "dns" with the as-yet undefined local variable "dns" # in https(). @@ -454,7 +454,7 @@ def https( post: bool = True, bootstrap_address: str | None = None, verify: bool | str | ssl.SSLContext = True, - resolver: Optional["dns.resolver.Resolver"] = None, # pyright: ignore + resolver: Optional["dns.resolver.Resolver"] = None, # type: ignore family: int = socket.AF_UNSPEC, http_version: HTTPVersion = HTTPVersion.DEFAULT, ) -> dns.message.Message: @@ -539,17 +539,17 @@ def https( ): if bootstrap_address is None: resolver = _maybe_get_resolver(resolver) - assert parsed.hostname is not None # pyright: ignore - answers = resolver.resolve_name(parsed.hostname, family) # pyright: ignore + assert parsed.hostname is not None # type: ignore + answers = resolver.resolve_name(parsed.hostname, family) # type: ignore bootstrap_address = random.choice(list(answers.addresses())) if session and not isinstance( session, dns.quic.SyncQuicConnection - ): # pyright: ignore + ): # type: ignore raise ValueError("session parameter must be a dns.quic.SyncQuicConnection.") return _http3( q, bootstrap_address, - url, # pyright: ignore + url, # type: ignore timeout, port, source, @@ -563,7 +563,7 @@ def https( if not have_doh: raise NoDOH # pragma: no cover - if session and not isinstance(session, httpx.Client): # pyright: ignore + if session and not isinstance(session, httpx.Client): # type: ignore raise ValueError("session parameter must be an httpx.Client") wire = q.to_wire() @@ -592,7 +592,7 @@ def https( local_port=local_port, bootstrap_address=bootstrap_address, resolver=resolver, - family=family, # pyright: ignore + family=family, # type: ignore ) cm = httpx.Client( # type: ignore @@ -704,7 +704,7 @@ def _http3( manager: contextlib.AbstractContextManager = contextlib.nullcontext(None) else: manager = dns.quic.SyncQuicManager( - verify_mode=verify, server_name=hostname, h3=True # pyright: ignore + verify_mode=verify, server_name=hostname, h3=True # type: ignore ) the_manager = manager # for type checking happiness @@ -712,11 +712,11 @@ def _http3( if connection: the_connection = connection else: - the_connection = the_manager.connect( # pyright: ignore + the_connection = the_manager.connect( # type: ignore where, port, source, source_port ) (start, expiration) = _compute_times(timeout) - with the_connection.make_stream(timeout) as stream: # pyright: ignore + with the_connection.make_stream(timeout) as stream: # type: ignore stream.send_h3(url, wire, post) wire = stream.receive(_remaining(expiration)) _check_status(stream.headers(), where, wire) @@ -1257,7 +1257,7 @@ def tcp( with cm as s: if not sock: # pylint: disable=possibly-used-before-assignment - _connect(s, destination, expiration) # pyright: ignore + _connect(s, destination, expiration) # type: ignore send_tcp(s, wire, expiration) (r, received_time) = receive_tcp( s, expiration, one_rr_per_rrset, q.keyring, q.mac, ignore_trailing @@ -1500,17 +1500,17 @@ def quic( the_connection = connection else: manager = dns.quic.SyncQuicManager( - verify_mode=verify, server_name=hostname # pyright: ignore + verify_mode=verify, server_name=hostname # type: ignore ) the_manager = manager # for type checking happiness with manager: if not connection: - the_connection = the_manager.connect( # pyright: ignore + the_connection = the_manager.connect( # type: ignore where, port, source, source_port ) (start, expiration) = _compute_times(timeout) - with the_connection.make_stream(timeout) as stream: # pyright: ignore + with the_connection.make_stream(timeout) as stream: # type: ignore stream.send(wire, True) wire = stream.receive(_remaining(expiration)) finish = time.time() diff --git a/dns/quic/__init__.py b/dns/quic/__init__.py index 7c2a699c..da8d2980 100644 --- a/dns/quic/__init__.py +++ b/dns/quic/__init__.py @@ -10,10 +10,10 @@ if dns._features.have("doq"): from dns.quic._asyncio import AsyncioQuicConnection as AsyncioQuicConnection from dns.quic._asyncio import AsyncioQuicManager from dns.quic._asyncio import AsyncioQuicStream as AsyncioQuicStream - from dns.quic._common import AsyncQuicConnection # pyright: ignore + from dns.quic._common import AsyncQuicConnection # type: ignore from dns.quic._common import AsyncQuicManager as AsyncQuicManager - from dns.quic._sync import SyncQuicConnection # pyright: ignore - from dns.quic._sync import SyncQuicStream # pyright: ignore + from dns.quic._sync import SyncQuicConnection # type: ignore + from dns.quic._sync import SyncQuicStream # type: ignore from dns.quic._sync import SyncQuicManager as SyncQuicManager have_quic = True diff --git a/dns/quic/_trio.py b/dns/quic/_trio.py index 046e6aab..c4dcc98d 100644 --- a/dns/quic/_trio.py +++ b/dns/quic/_trio.py @@ -112,7 +112,7 @@ class TrioQuicConnection(AsyncQuicConnection): # race. interval = 0.0 with trio.CancelScope( - deadline=trio.current_time() + interval # pyright: ignore + deadline=trio.current_time() + interval # type: ignore ) as self._worker_scope: datagram = await self._socket.recv(QUIC_MAX_DATAGRAM) self._connection.receive_datagram(datagram, self._peer, time.time()) diff --git a/dns/rdata.py b/dns/rdata.py index c4522e68..4a162cb9 100644 --- a/dns/rdata.py +++ b/dns/rdata.py @@ -635,7 +635,7 @@ class GenericRdata(Rdata): relativize: bool = True, **kw: Dict[str, Any], ) -> str: - return rf"\# {len(self.data)} " + _hexify(self.data, **kw) # pyright: ignore + return rf"\# {len(self.data)} " + _hexify(self.data, **kw) # type: ignore @classmethod def from_text( diff --git a/dns/rdataset.py b/dns/rdataset.py index 1edf67d7..1673aad7 100644 --- a/dns/rdataset.py +++ b/dns/rdataset.py @@ -98,9 +98,7 @@ class Rdataset(dns.set.Set): self.ttl = ttl # pylint: disable=arguments-differ,arguments-renamed - def add( # pyright: ignore - self, rd: dns.rdata.Rdata, ttl: int | None = None - ) -> None: + def add(self, rd: dns.rdata.Rdata, ttl: int | None = None) -> None: # type: ignore """Add the specified rdata to the rdataset. If the optional *ttl* parameter is supplied, then @@ -351,7 +349,7 @@ class Rdataset(dns.set.Set): if len(self) == 0: return [] else: - return self[0]._processing_order(iter(self)) # pyright: ignore + return self[0]._processing_order(iter(self)) # type: ignore @dns.immutable.immutable @@ -406,22 +404,22 @@ class ImmutableRdataset(Rdataset): # lgtm[py/missing-equals] raise TypeError("immutable") def __copy__(self): - return ImmutableRdataset(super().copy()) # pyright: ignore + return ImmutableRdataset(super().copy()) # type: ignore def copy(self): - return ImmutableRdataset(super().copy()) # pyright: ignore + return ImmutableRdataset(super().copy()) # type: ignore def union(self, other): - return ImmutableRdataset(super().union(other)) # pyright: ignore + return ImmutableRdataset(super().union(other)) # type: ignore def intersection(self, other): - return ImmutableRdataset(super().intersection(other)) # pyright: ignore + return ImmutableRdataset(super().intersection(other)) # type: ignore def difference(self, other): - return ImmutableRdataset(super().difference(other)) # pyright: ignore + return ImmutableRdataset(super().difference(other)) # type: ignore def symmetric_difference(self, other): - return ImmutableRdataset(super().symmetric_difference(other)) # pyright: ignore + return ImmutableRdataset(super().symmetric_difference(other)) # type: ignore def from_text_list( diff --git a/dns/rdtypes/ANY/CERT.py b/dns/rdtypes/ANY/CERT.py index 4d5e5bda..f00500fa 100644 --- a/dns/rdtypes/ANY/CERT.py +++ b/dns/rdtypes/ANY/CERT.py @@ -85,7 +85,7 @@ class CERT(dns.rdata.Rdata): def to_text(self, origin=None, relativize=True, **kw): certificate_type = _ctype_to_text(self.certificate_type) algorithm = dns.dnssectypes.Algorithm.to_text(self.algorithm) - certificate = dns.rdata._base64ify(self.certificate, **kw) # pyright: ignore + certificate = dns.rdata._base64ify(self.certificate, **kw) # type: ignore return f"{certificate_type} {self.key_tag} {algorithm} {certificate}" @classmethod diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py index 6c7fe5e7..89048a58 100644 --- a/dns/rdtypes/ANY/LOC.py +++ b/dns/rdtypes/ANY/LOC.py @@ -143,13 +143,13 @@ class LOC(dns.rdata.Rdata): if isinstance(latitude, float): latitude = _float_to_tuple(latitude) _check_coordinate_list(latitude, -90, 90) - self.latitude = tuple(latitude) # pyright: ignore + self.latitude = tuple(latitude) # type: ignore if isinstance(longitude, int): longitude = float(longitude) if isinstance(longitude, float): longitude = _float_to_tuple(longitude) _check_coordinate_list(longitude, -180, 180) - self.longitude = tuple(longitude) # pyright: ignore + self.longitude = tuple(longitude) # type: ignore self.altitude = float(altitude) self.size = float(size) self.horizontal_precision = float(hprec) diff --git a/dns/rdtypes/ANY/OPENPGPKEY.py b/dns/rdtypes/ANY/OPENPGPKEY.py index ac1841cc..25af4725 100644 --- a/dns/rdtypes/ANY/OPENPGPKEY.py +++ b/dns/rdtypes/ANY/OPENPGPKEY.py @@ -34,7 +34,7 @@ class OPENPGPKEY(dns.rdata.Rdata): self.key = self._as_bytes(key) def to_text(self, origin=None, relativize=True, **kw): - return dns.rdata._base64ify(self.key, chunksize=None, **kw) # pyright: ignore + return dns.rdata._base64ify(self.key, chunksize=None, **kw) # type: ignore @classmethod def from_text( diff --git a/dns/rdtypes/ANY/SSHFP.py b/dns/rdtypes/ANY/SSHFP.py index 3f08f3a5..c6b272f2 100644 --- a/dns/rdtypes/ANY/SSHFP.py +++ b/dns/rdtypes/ANY/SSHFP.py @@ -41,7 +41,7 @@ class SSHFP(dns.rdata.Rdata): kw = kw.copy() chunksize = kw.pop("chunksize", 128) fingerprint = dns.rdata._hexify( - self.fingerprint, chunksize=chunksize, **kw # pyright: ignore + self.fingerprint, chunksize=chunksize, **kw # type: ignore ) return f"{self.algorithm} {self.fp_type} {fingerprint}" diff --git a/dns/rdtypes/ANY/ZONEMD.py b/dns/rdtypes/ANY/ZONEMD.py index acef4f27..420cbf4e 100644 --- a/dns/rdtypes/ANY/ZONEMD.py +++ b/dns/rdtypes/ANY/ZONEMD.py @@ -37,7 +37,7 @@ class ZONEMD(dns.rdata.Rdata): kw = kw.copy() chunksize = kw.pop("chunksize", 128) digest = dns.rdata._hexify( - self.digest, chunksize=chunksize, **kw # pyright: ignore + self.digest, chunksize=chunksize, **kw # type: ignore ) return f"{self.serial} {self.scheme} {self.hash_algorithm} {digest}" diff --git a/dns/rdtypes/IN/DHCID.py b/dns/rdtypes/IN/DHCID.py index 8de8cdf1..5b54d1ba 100644 --- a/dns/rdtypes/IN/DHCID.py +++ b/dns/rdtypes/IN/DHCID.py @@ -35,7 +35,7 @@ class DHCID(dns.rdata.Rdata): self.data = self._as_bytes(data) def to_text(self, origin=None, relativize=True, **kw): - return dns.rdata._base64ify(self.data, **kw) # pyright: ignore + return dns.rdata._base64ify(self.data, **kw) # type: ignore @classmethod def from_text( diff --git a/dns/rdtypes/IN/IPSECKEY.py b/dns/rdtypes/IN/IPSECKEY.py index aef93ae1..e347e594 100644 --- a/dns/rdtypes/IN/IPSECKEY.py +++ b/dns/rdtypes/IN/IPSECKEY.py @@ -49,7 +49,7 @@ class IPSECKEY(dns.rdata.Rdata): def to_text(self, origin=None, relativize=True, **kw): gateway = Gateway(self.gateway_type, self.gateway).to_text(origin, relativize) - key = dns.rdata._base64ify(self.key, **kw) # pyright: ignore + key = dns.rdata._base64ify(self.key, **kw) # type: ignore return f"{self.precedence} {self.gateway_type} {self.algorithm} {gateway} {key}" @classmethod diff --git a/dns/rdtypes/dnskeybase.py b/dns/rdtypes/dnskeybase.py index fb49f922..a75c8fcd 100644 --- a/dns/rdtypes/dnskeybase.py +++ b/dns/rdtypes/dnskeybase.py @@ -48,7 +48,7 @@ class DNSKEYBase(dns.rdata.Rdata): self.key = self._as_bytes(key) def to_text(self, origin=None, relativize=True, **kw): - key = dns.rdata._base64ify(self.key, **kw) # pyright: ignore + key = dns.rdata._base64ify(self.key, **kw) # type: ignore return f"{self.flags} {self.protocol} {self.algorithm} {key}" @classmethod diff --git a/dns/rdtypes/dsbase.py b/dns/rdtypes/dsbase.py index 8e05c2a7..ccf76012 100644 --- a/dns/rdtypes/dsbase.py +++ b/dns/rdtypes/dsbase.py @@ -56,7 +56,7 @@ class DSBase(dns.rdata.Rdata): kw = kw.copy() chunksize = kw.pop("chunksize", 128) digest = dns.rdata._hexify( - self.digest, chunksize=chunksize, **kw # pyright: ignore + self.digest, chunksize=chunksize, **kw # type: ignore ) return f"{self.key_tag} {self.algorithm} {self.digest_type} {digest}" diff --git a/dns/rdtypes/rrsigbase.py b/dns/rdtypes/rrsigbase.py index 0d240bd4..87e000b7 100644 --- a/dns/rdtypes/rrsigbase.py +++ b/dns/rdtypes/rrsigbase.py @@ -98,7 +98,7 @@ class RRSIGBase(dns.rdata.Rdata): expiration = posixtime_to_sigtime(self.expiration) inception = posixtime_to_sigtime(self.inception) signer = self.signer.choose_relativity(origin, relativize) - sig = dns.rdata._base64ify(self.signature, **kw) # pyright: ignore + sig = dns.rdata._base64ify(self.signature, **kw) # type: ignore return ( f"{ctext} {self.algorithm} {self.labels} {self.original_ttl} " + f"{expiration} {inception} {self.key_tag} {signer} {sig}" @@ -152,4 +152,4 @@ class RRSIGBase(dns.rdata.Rdata): header = parser.get_struct("!HBBIIIH") signer = parser.get_name(origin) signature = parser.get_remaining() - return cls(rdclass, rdtype, *header, signer, signature) # pyright: ignore + return cls(rdclass, rdtype, *header, signer, signature) # type: ignore diff --git a/dns/rdtypes/tlsabase.py b/dns/rdtypes/tlsabase.py index ddc196f1..e5ff0260 100644 --- a/dns/rdtypes/tlsabase.py +++ b/dns/rdtypes/tlsabase.py @@ -41,9 +41,7 @@ class TLSABase(dns.rdata.Rdata): def to_text(self, origin=None, relativize=True, **kw): kw = kw.copy() chunksize = kw.pop("chunksize", 128) - cert = dns.rdata._hexify( - self.cert, chunksize=chunksize, **kw # pyright: ignore - ) + cert = dns.rdata._hexify(self.cert, chunksize=chunksize, **kw) # type: ignore return f"{self.usage} {self.selector} {self.mtype} {cert}" @classmethod diff --git a/dns/rdtypes/util.py b/dns/rdtypes/util.py index c17b154b..e1730db5 100644 --- a/dns/rdtypes/util.py +++ b/dns/rdtypes/util.py @@ -247,10 +247,10 @@ def weighted_processing_order(iterable): if weight > r: break r -= weight - total -= weight # pyright: ignore[reportPossiblyUnboundVariable] + total -= weight # type: ignore # pylint: disable=undefined-loop-variable - ordered.append(rdata) # pyright: ignore[reportPossiblyUnboundVariable] - del rdatas[n] # pyright: ignore[reportPossiblyUnboundVariable] + ordered.append(rdata) # type: ignore + del rdatas[n] # type: ignore ordered.append(rdatas[0]) return ordered diff --git a/dns/renderer.py b/dns/renderer.py index cc912b29..4885348e 100644 --- a/dns/renderer.py +++ b/dns/renderer.py @@ -219,7 +219,7 @@ class Renderer: pad = b"" options = list(opt_rdata.options) options.append(dns.edns.GenericOption(dns.edns.OptionType.PADDING, pad)) - opt = dns.message.Message._make_opt( # pyright: ignore + opt = dns.message.Message._make_opt( # type: ignore ttl, opt_rdata.rdclass, options ) self.was_padded = True @@ -231,9 +231,7 @@ class Renderer: # make sure the EDNS version in ednsflags agrees with edns ednsflags &= 0xFF00FFFF ednsflags |= edns << 16 - opt = dns.message.Message._make_opt( # pyright: ignore - ednsflags, payload, options - ) + opt = dns.message.Message._make_opt(ednsflags, payload, options) # type: ignore self.add_opt(opt) def add_tsig( @@ -255,7 +253,7 @@ class Renderer: key = secret else: key = dns.tsig.Key(keyname, secret, algorithm) - tsig = dns.message.Message._make_tsig( # pyright: ignore + tsig = dns.message.Message._make_tsig( # type: ignore keyname, algorithm, 0, fudge, b"", id, tsig_error, other_data ) (tsig, _) = dns.tsig.sign(s, key, tsig[0], int(time.time()), request_mac) @@ -287,7 +285,7 @@ class Renderer: key = secret else: key = dns.tsig.Key(keyname, secret, algorithm) - tsig = dns.message.Message._make_tsig( # pyright: ignore + tsig = dns.message.Message._make_tsig( # type: ignore keyname, algorithm, 0, fudge, b"", id, tsig_error, other_data ) (tsig, ctx) = dns.tsig.sign( diff --git a/dns/resolver.py b/dns/resolver.py index 6bcbb5d5..f6d239ab 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -64,7 +64,7 @@ class NXDOMAIN(dns.exception.DNSException): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def _check_kwargs(self, qnames, responses=None): # pyright: ignore + def _check_kwargs(self, qnames, responses=None): # type: ignore if not isinstance(qnames, list | tuple | set): raise AttributeError("qnames must be a list, tuple or set") if len(qnames) == 0: @@ -1663,7 +1663,7 @@ def zone_for_name( tcp: bool = False, resolver: Resolver | None = None, lifetime: float | None = None, -) -> dns.name.Name: # pyright: ignore[reportReturnType] +) -> dns.name.Name: # type: ignore[reportReturnType] """Find the name of the zone which contains the specified name. *name*, an absolute ``dns.name.Name`` or ``str``, the query name. @@ -1899,7 +1899,7 @@ def _getaddrinfo( except Exception: if flags & socket.AI_NUMERICSERV == 0: try: - port = socket.getservbyname(service) # pyright: ignore + port = socket.getservbyname(service) # type: ignore except Exception: pass if port is None: diff --git a/dns/update.py b/dns/update.py index 0e4aee41..41370ac7 100644 --- a/dns/update.py +++ b/dns/update.py @@ -354,7 +354,7 @@ class UpdateMessage(dns.message.Message): # lgtm[py/missing-equals] # Updates are always one_rr_per_rrset return True - def _parse_rr_header(self, section, name, rdclass, rdtype): # pyright: ignore + def _parse_rr_header(self, section, name, rdclass, rdtype): # type: ignore deleting = None empty = False if section == UpdateSection.ZONE: diff --git a/dns/versioned.py b/dns/versioned.py index 3644711e..28d1d41e 100644 --- a/dns/versioned.py +++ b/dns/versioned.py @@ -188,7 +188,7 @@ class Zone(dns.zone.Zone): # lgtm[py/missing-equals] # Note our definition of least_kept also ensures we do not try to # delete the greatest version. if len(self._readers) > 0: - least_kept = min(txn.version.id for txn in self._readers) # pyright: ignore + least_kept = min(txn.version.id for txn in self._readers) # type: ignore else: least_kept = self._versions[-1].id while self._versions[0].id < least_kept and self._pruning_policy( @@ -204,7 +204,7 @@ class Zone(dns.zone.Zone): # lgtm[py/missing-equals] raise ValueError("max versions must be at least 1") if max_versions is None: # pylint: disable=unused-argument - def policy(zone, _): # pyright: ignore + def policy(zone, _): # type: ignore return False else: diff --git a/dns/xfr.py b/dns/xfr.py index d0f44da8..5f21fea8 100644 --- a/dns/xfr.py +++ b/dns/xfr.py @@ -137,7 +137,7 @@ class Inbound: if rdataset.rdtype != dns.rdatatype.SOA: raise dns.exception.FormError("first RRset is not an SOA") answer_index = 1 - self.soa_rdataset = rdataset.copy() # pyright: ignore + self.soa_rdataset = rdataset.copy() # type: ignore if self.incremental: assert self.soa_rdataset is not None soa = cast(dns.rdtypes.ANY.SOA.SOA, self.soa_rdataset[0]) diff --git a/dns/zone.py b/dns/zone.py index 0dfecc92..02e1f209 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -697,9 +697,9 @@ class Zone(dns.transaction.TransactionManager): for n in names: l = self[n].to_text( n, - origin=self.origin, # pyright: ignore - relativize=relativize, # pyright: ignore - want_comments=want_comments, # pyright: ignore + origin=self.origin, # type: ignore + relativize=relativize, # type: ignore + want_comments=want_comments, # type: ignore ) l_b = l.encode(file_enc) @@ -1116,10 +1116,10 @@ class Transaction(dns.transaction.Transaction): def _setup_version(self): assert self.version is None - factory = self.manager.writable_version_factory # pyright: ignore + factory = self.manager.writable_version_factory # type: ignore if factory is None: factory = WritableVersion - self.version = factory(self.zone, self.replacement) # pyright: ignore + self.version = factory(self.zone, self.replacement) # type: ignore def _get_rdataset(self, name, rdtype, covers): assert self.version is not None @@ -1155,22 +1155,22 @@ class Transaction(dns.transaction.Transaction): assert self.zone is not None assert self.version is not None if self.read_only: - self.zone._end_read(self) # pyright: ignore + self.zone._end_read(self) # type: ignore elif commit and len(self.version.changed) > 0: if self.make_immutable: - factory = self.manager.immutable_version_factory # pyright: ignore + factory = self.manager.immutable_version_factory # type: ignore if factory is None: factory = ImmutableVersion version = factory(self.version) else: version = self.version - self.zone._commit_version( # pyright: ignore + self.zone._commit_version( # type: ignore self, version, self.version.origin ) else: # rollback - self.zone._end_write(self) # pyright: ignore + self.zone._end_write(self) # type: ignore def _set_origin(self, origin): assert self.version is not None diff --git a/dns/zonefile.py b/dns/zonefile.py index 7a81454b..78fd13e2 100644 --- a/dns/zonefile.py +++ b/dns/zonefile.py @@ -615,7 +615,7 @@ class RRsetsReaderTransaction(dns.transaction.Transaction): ) rrset.update(rdataset) rrsets.append(rrset) - self.manager.set_rrsets(rrsets) # pyright: ignore + self.manager.set_rrsets(rrsets) # type: ignore def _set_origin(self, origin): pass -- 2.47.3