]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
fix issues found with latest version of pyright
authorBob Halley <halley@dnspython.org>
Wed, 26 Mar 2025 13:22:28 +0000 (06:22 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 26 Mar 2025 13:22:28 +0000 (06:22 -0700)
dns/_asyncio_backend.py
dns/query.py
dns/resolver.py

index 99656d4467a373e7ae36f4fe84048ce3a580e807..303908cebf6e637307f3d1e04d233f24db6bc0e1 100644 (file)
@@ -131,7 +131,7 @@ if dns._features.have("doh"):
     import httpx
 
     _CoreAsyncNetworkBackend = httpcore.AsyncNetworkBackend
-    _CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream
+    _CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream  # pyright: ignore
 
     from dns.query import _compute_times, _expiration_for_this_attempt, _remaining
 
index 5d57666c2655cd51ddb20a40840497f63238206f..e4f7ac680b680d5edce2dc2b90445c7f802a8a56 100644 (file)
@@ -550,6 +550,7 @@ def https(
     with cm as session:
         # see https://tools.ietf.org/html/rfc8484#section-4.1.1 for DoH
         # GET and POST examples
+        assert session is not None
         if post:
             headers.update(
                 {
index 6e160484ed29581b106129372a9282a958164707..47e2556b7c439918349d3c79d08aa8c6ebaca484 100644 (file)
@@ -318,6 +318,10 @@ class Answers(dict):
     """A dict of DNS stub resolver answers, indexed by type."""
 
 
+class EmptyHostAnswers(dns.exception.DNSException):
+    """The HostAnswers has no addresses"""
+
+
 class HostAnswers(Answers):
     """A dict of DNS stub resolver answers to a host name lookup, indexed by
     type.
@@ -364,6 +368,8 @@ class HostAnswers(Answers):
     # Returns the canonical name from this result.
     def canonical_name(self) -> dns.name.Name:
         answer = self.get(dns.rdatatype.AAAA, self.get(dns.rdatatype.A))
+        if answer is None:
+            raise EmptyHostAnswers
         return answer.canonical_name