diff options
author | Bob Halley <halley@dnspython.org> | 2023-03-19 09:49:25 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2023-03-19 09:49:25 -0700 |
commit | 8231eaabac049e74298856c957645dac6d196dc8 (patch) | |
tree | 716fc47bf3238105639bbfbab78d4d9ec1841452 | |
parent | 67daa993805b97ba1dc57245ecf3af2e55729df6 (diff) | |
download | dnspython-8231eaabac049e74298856c957645dac6d196dc8.tar.gz |
linting + have asyncio HTTP code actually connect to right address
-rw-r--r-- | dns/_asyncio_backend.py | 17 | ||||
-rw-r--r-- | dns/_trio_backend.py | 15 | ||||
-rw-r--r-- | dns/query.py | 13 |
3 files changed, 37 insertions, 8 deletions
diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index 98971be..bce6e4d 100644 --- a/dns/_asyncio_backend.py +++ b/dns/_asyncio_backend.py @@ -135,9 +135,11 @@ try: "the asyncio transport for HTTPX cannot set the local port" ) - async def connect_tcp(self, host, port, timeout, local_address): + async def connect_tcp( + self, host, port, timeout, local_address + ): # pylint: disable=signature-differs addresses = [] - now, expiration = _compute_times(timeout) + _, expiration = _compute_times(timeout) if dns.inet.is_address(host): addresses.append(host) elif self._bootstrap_address is not None: @@ -157,7 +159,7 @@ try: timeout = _remaining(attempt_expiration) with anyio.fail_after(timeout): stream = await anyio.connect_tcp( - remote_host=host, + remote_host=address, remote_port=port, local_host=local_address, ) @@ -166,6 +168,14 @@ try: pass raise httpcore.ConnectError + async def connect_unix_socket( + self, path, timeout + ): # pylint: disable=signature-differs + raise NotImplementedError + + async def sleep(self, seconds): # pylint: disable=signature-differs + await anyio.sleep(seconds) + class _HTTPTransport(httpx.AsyncHTTPTransport): def __init__( self, @@ -177,6 +187,7 @@ try: **kwargs, ): if resolver is None: + # pylint: disable=import-outside-toplevel,redefined-outer-name import dns.asyncresolver resolver = dns.asyncresolver.Resolver() diff --git a/dns/_trio_backend.py b/dns/_trio_backend.py index 08101f9..3652195 100644 --- a/dns/_trio_backend.py +++ b/dns/_trio_backend.py @@ -100,9 +100,11 @@ try: self._bootstrap_address = bootstrap_address self._family = family - async def connect_tcp(self, host, port, timeout, local_address): + async def connect_tcp( + self, host, port, timeout, local_address + ): # pylint: disable=signature-differs addresses = [] - now, expiration = _compute_times(timeout) + _, expiration = _compute_times(timeout) if dns.inet.is_address(host): addresses.append(host) elif self._bootstrap_address is not None: @@ -134,6 +136,14 @@ try: continue raise httpcore.ConnectError + async def connect_unix_socket( + self, path, timeout + ): # pylint: disable=signature-differs + raise NotImplementedError + + async def sleep(self, seconds): # pylint: disable=signature-differs + await trio.sleep(seconds) + class _HTTPTransport(httpx.AsyncHTTPTransport): def __init__( self, @@ -145,6 +155,7 @@ try: **kwargs, ): if resolver is None: + # pylint: disable=import-outside-toplevel,redefined-outer-name import dns.asyncresolver resolver = dns.asyncresolver.Resolver() diff --git a/dns/query.py b/dns/query.py index 517bab0..f34330f 100644 --- a/dns/query.py +++ b/dns/query.py @@ -28,7 +28,6 @@ import selectors import socket import struct import time -import urllib.parse import dns.exception import dns.inet @@ -84,9 +83,11 @@ try: self._bootstrap_address = bootstrap_address self._family = family - def connect_tcp(self, host, port, timeout, local_address): + def connect_tcp( + self, host, port, timeout, local_address + ): # pylint: disable=signature-differs addresses = [] - now, expiration = _compute_times(timeout) + _, expiration = _compute_times(timeout) if dns.inet.is_address(host): addresses.append(host) elif self._bootstrap_address is not None: @@ -121,6 +122,11 @@ try: pass raise httpcore.ConnectError + def connect_unix_socket( + self, path, timeout + ): # pylint: disable=signature-differs + raise NotImplementedError + class _HTTPTransport(httpx.HTTPTransport): def __init__( self, @@ -132,6 +138,7 @@ try: **kwargs, ): if resolver is None: + # pylint: disable=import-outside-toplevel,redefined-outer-name import dns.resolver resolver = dns.resolver.Resolver() |