Skip to content

Commit

Permalink
pyright lint for async backends
Browse files Browse the repository at this point in the history
  • Loading branch information
rthalley committed Oct 16, 2024
1 parent 971a7a2 commit e8a7e20
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dns/_asyncbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def connect_tcp(self, host, port, timeout, local_address):


class Backend: # pragma: no cover
def name(self):
def name(self) -> str:
return "unknown"

async def make_socket(
Expand Down
9 changes: 5 additions & 4 deletions dns/_asyncio_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def connection_lost(self, exc):
self.recvfrom.set_exception(exc)

def close(self):
self.transport.close()
if self.transport is not None:
self.transport.close()


async def _maybe_wait_for(awaitable, timeout):
Expand Down Expand Up @@ -147,7 +148,7 @@ def __init__(self, resolver, local_port, bootstrap_address, family):
)

async def connect_tcp(
self, host, port, timeout, local_address, socket_options=None
self, host, port, timeout=None, local_address=None, socket_options=None
): # pylint: disable=signature-differs
addresses = []
_, expiration = _compute_times(timeout)
Expand Down Expand Up @@ -180,7 +181,7 @@ async def connect_tcp(
raise httpcore.ConnectError

async def connect_unix_socket(
self, path, timeout, socket_options=None
self, path, timeout=None, socket_options=None
): # pylint: disable=signature-differs
raise NotImplementedError

Expand Down Expand Up @@ -233,7 +234,7 @@ async def make_socket(
# proper fix for [#637].
source = (dns.inet.any_for_af(af), 0)
transport, protocol = await loop.create_datagram_endpoint(
_DatagramProtocol,
_DatagramProtocol, # pyright: ignore
source,
family=af,
proto=proto,
Expand Down
6 changes: 4 additions & 2 deletions dns/_trio_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, resolver, local_port, bootstrap_address, family):
self._family = family

async def connect_tcp(
self, host, port, timeout, local_address, socket_options=None
self, host, port, timeout=None, local_address=None, socket_options=None
): # pylint: disable=signature-differs
addresses = []
_, expiration = _compute_times(timeout)
Expand Down Expand Up @@ -151,13 +151,14 @@ async def connect_tcp(
sock = await Backend().make_socket(
af, socket.SOCK_STREAM, 0, source, destination, timeout
)
assert isinstance(sock, StreamSocket)
return _CoreTrioStream(sock.stream)
except Exception:
continue
raise httpcore.ConnectError

async def connect_unix_socket(
self, path, timeout, socket_options=None
self, path, timeout=None, socket_options=None
): # pylint: disable=signature-differs
raise NotImplementedError

Expand Down Expand Up @@ -211,6 +212,7 @@ async def make_socket(
if socktype == socket.SOCK_STREAM or destination is not None:
connected = False
with _maybe_timeout(timeout):
assert destination is not None
await s.connect(_lltuple(destination, af))
connected = True
if not connected:
Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,4 @@ ignore_missing_imports = true

[tool.pyright]
reportUnsupportedDunderAll = false
exclude = [
"dns/_*_backend.py",
"dns/quic/*.py",
"examples/*.py",
"tests/*.py",
] # (mostly) temporary!
exclude = ["dns/quic/*.py", "examples/*.py", "tests/*.py"] # (mostly) temporary!

0 comments on commit e8a7e20

Please sign in to comment.