fix: address code review comments (type hints, loop var name, em dashes)
Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/be0a3bbd-1af1-408e-b918-84753723154b Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
45a2dd8be2
commit
28a7592731
@@ -133,7 +133,7 @@ class _POP3WithIPv4Pref(poplib.POP3):
|
|||||||
self._ipv4_addr = _ipv4_addr
|
self._ipv4_addr = _ipv4_addr
|
||||||
super().__init__(host, port, timeout)
|
super().__init__(host, port, timeout)
|
||||||
|
|
||||||
def _create_socket(self, timeout): # type: ignore[override]
|
def _create_socket(self, timeout: Any) -> socket.socket: # type: ignore[override]
|
||||||
if self._ipv4_addr:
|
if self._ipv4_addr:
|
||||||
return socket.create_connection((self._ipv4_addr, self.port), timeout)
|
return socket.create_connection((self._ipv4_addr, self.port), timeout)
|
||||||
return super()._create_socket(timeout)
|
return super()._create_socket(timeout)
|
||||||
@@ -162,7 +162,7 @@ class _POP3SSLWithIPv4Pref(poplib.POP3_SSL):
|
|||||||
self._ipv4_addr = _ipv4_addr
|
self._ipv4_addr = _ipv4_addr
|
||||||
super().__init__(host, port, timeout=timeout, context=context)
|
super().__init__(host, port, timeout=timeout, context=context)
|
||||||
|
|
||||||
def _create_socket(self, timeout): # type: ignore[override]
|
def _create_socket(self, timeout: Any) -> socket.socket: # type: ignore[override]
|
||||||
if self._ipv4_addr:
|
if self._ipv4_addr:
|
||||||
return socket.create_connection((self._ipv4_addr, self.port), timeout)
|
return socket.create_connection((self._ipv4_addr, self.port), timeout)
|
||||||
return super()._create_socket(timeout)
|
return super()._create_socket(timeout)
|
||||||
@@ -235,10 +235,10 @@ class _IMAP4SSLwithSNI(aioimaplib.IMAP4_SSL):
|
|||||||
) -> None:
|
) -> None:
|
||||||
if ssl_context is None:
|
if ssl_context is None:
|
||||||
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
|
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
|
||||||
local_loop = loop if loop is not None else asyncio.get_running_loop()
|
active_loop = loop if loop is not None else asyncio.get_running_loop()
|
||||||
self.protocol = aioimaplib.IMAP4ClientProtocol(local_loop, conn_lost_cb)
|
self.protocol = aioimaplib.IMAP4ClientProtocol(active_loop, conn_lost_cb)
|
||||||
self._client_task = local_loop.create_task(
|
self._client_task = active_loop.create_task(
|
||||||
local_loop.create_connection(
|
active_loop.create_connection(
|
||||||
lambda: self.protocol,
|
lambda: self.protocol,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
@@ -314,13 +314,13 @@ def _format_connection_error(
|
|||||||
|
|
||||||
# DNS resolution failure (socket.gaierror is a subclass of OSError)
|
# DNS resolution failure (socket.gaierror is a subclass of OSError)
|
||||||
if isinstance(exc, socket.gaierror):
|
if isinstance(exc, socket.gaierror):
|
||||||
# errno -3 / EAI_AGAIN means the DNS server is temporarily unavailable –
|
# errno -3 / EAI_AGAIN means the DNS server is temporarily unavailable --
|
||||||
# this is a transient infrastructure error, not a misconfigured address.
|
# this is a transient infrastructure error, not a misconfigured address.
|
||||||
if exc.args[0] == socket.EAI_AGAIN:
|
if exc.args[0] == socket.EAI_AGAIN:
|
||||||
if host:
|
if host:
|
||||||
return (
|
return (
|
||||||
f"Temporary DNS failure while resolving '{host}' — "
|
f"Temporary DNS failure while resolving '{host}' --"
|
||||||
f"the DNS server may be temporarily unavailable ({exc})"
|
f" the DNS server may be temporarily unavailable ({exc})"
|
||||||
)
|
)
|
||||||
return f"Temporary DNS failure: {exc}"
|
return f"Temporary DNS failure: {exc}"
|
||||||
if host:
|
if host:
|
||||||
|
|||||||
Reference in New Issue
Block a user