From: Bob Halley Date: Wed, 26 Mar 2025 13:22:28 +0000 (-0700) Subject: fix issues found with latest version of pyright X-Git-Tag: v2.8.0rc1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcb4c1621fc0351eb8a92cb36ecdb75be2977da5;p=thirdparty%2Fdnspython.git fix issues found with latest version of pyright --- diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index 99656d44..303908ce 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 + _CoreAnyIOStream = httpcore._backends.anyio.AnyIOStream # pyright: ignore from dns.query import _compute_times, _expiration_for_this_attempt, _remaining diff --git a/dns/query.py b/dns/query.py index 5d57666c..e4f7ac68 100644 --- a/dns/query.py +++ b/dns/query.py @@ -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( { diff --git a/dns/resolver.py b/dns/resolver.py index 6e160484..47e2556b 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -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