Skip to content
Prev Previous commit
Next Next commit
pyright updates
  • Loading branch information
SamRemis committed Nov 18, 2025
commit bba7c153ea4ae28a8c87bc777a89437a31620454
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ClientTransport[I: Request, O: Response](Protocol):
exceptions represent timeout conditions for that transport.
"""

def get_error_info(self, exception: Exception, **kwargs) -> ErrorInfo:
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
"""Get information about an exception.

Args:
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-core/src/smithy_core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ClientTimeoutError(CallError):

fault: Fault = "client"
is_timeout_error: bool = True
is_retry_safe: bool = True
is_retry_safe: bool | None = True


class SerializationError(SmithyError):
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-http/src/smithy_http/aio/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __post_init__(self) -> None:
class AIOHTTPClient(HTTPClient):
"""Implementation of :py:class:`.interfaces.HTTPClient` using aiohttp."""

def get_error_info(self, exception: Exception, **kwargs) -> ErrorInfo:
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
"""Get information about aiohttp errors."""

if isinstance(exception, TimeoutError):
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-http/src/smithy_http/aio/crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient):
_HTTP_PORT = 80
_HTTPS_PORT = 443

def get_error_info(self, exception: Exception, **kwargs) -> ErrorInfo:
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
"""Get information about CRT errors."""

timeout_indicators = (
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-http/tests/unit/aio/test_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async def test_http_408_creates_timeout_error() -> None:

response = HTTPResponse(status=408, fields=Fields())

error = await HttpBindingClientProtocol._create_error(
error = await HttpBindingClientProtocol._create_error( # type: ignore[reportPrivateUsage]
protocol,
operation=Mock(),
request=HTTPRequest(
Expand Down
30 changes: 18 additions & 12 deletions packages/smithy-http/tests/unit/aio/test_timeout_errors.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,68 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from typing import TYPE_CHECKING

import pytest
from smithy_core.aio.interfaces import ErrorInfo

if TYPE_CHECKING:
from smithy_http.aio.aiohttp import AIOHTTPClient
from smithy_http.aio.crt import AWSCRTHTTPClient

try:
from smithy_http.aio.aiohttp import AIOHTTPClient

HAS_AIOHTTP = True
has_aiohttp = True
except ImportError:
HAS_AIOHTTP = False
has_aiohttp = False

try:
from smithy_http.aio.crt import AWSCRTHTTPClient

HAS_CRT = True
has_crt = True
except ImportError:
HAS_CRT = False
has_crt = False


@pytest.mark.skipif(not HAS_AIOHTTP, reason="aiohttp not available")
@pytest.mark.skipif(not has_aiohttp, reason="aiohttp not available")
class TestAIOHTTPTimeoutErrorHandling:
"""Test timeout error handling for AIOHTTPClient."""

@pytest.fixture
async def client(self):
async def client(self) -> "AIOHTTPClient":
return AIOHTTPClient()

@pytest.mark.asyncio
async def test_timeout_error_detection(self, client):
async def test_timeout_error_detection(self, client: "AIOHTTPClient") -> None:
"""Test timeout error detection for standard TimeoutError."""
timeout_err = TimeoutError("Connection timed out")
result = client.get_error_info(timeout_err)
assert result == ErrorInfo(is_timeout_error=True, fault="client")

@pytest.mark.asyncio
async def test_non_timeout_error_detection(self, client):
async def test_non_timeout_error_detection(self, client: "AIOHTTPClient") -> None:
"""Test non-timeout error detection."""
other_err = ValueError("Not a timeout")
result = client.get_error_info(other_err)
assert result == ErrorInfo(is_timeout_error=False, fault="client")


@pytest.mark.skipif(not HAS_CRT, reason="AWS CRT not available")
@pytest.mark.skipif(not has_crt, reason="AWS CRT not available")
class TestAWSCRTTimeoutErrorHandling:
"""Test timeout error handling for AWSCRTHTTPClient."""

@pytest.fixture
def client(self):
def client(self) -> "AWSCRTHTTPClient":
return AWSCRTHTTPClient()

def test_timeout_error_detection(self, client):
def test_timeout_error_detection(self, client: "AWSCRTHTTPClient") -> None:
"""Test timeout error detection for standard TimeoutError."""
timeout_err = TimeoutError("Connection timed out")
result = client.get_error_info(timeout_err)
assert result == ErrorInfo(is_timeout_error=True, fault="client")

def test_non_timeout_error_detection(self, client):
def test_non_timeout_error_detection(self, client: "AWSCRTHTTPClient") -> None:
"""Test non-timeout error detection."""
other_err = ValueError("Not a timeout")
result = client.get_error_info(other_err)
Expand Down