Skip to content

Commit 06ece22

Browse files
committed
pyright updates
1 parent 1c8bed7 commit 06ece22

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

packages/smithy-core/src/smithy_core/aio/interfaces/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ClientTransport[I: Request, O: Response](Protocol):
105105
exceptions represent timeout conditions for that transport.
106106
"""
107107

108-
def get_error_info(self, exception: Exception, **kwargs) -> ErrorInfo:
108+
def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo:
109109
"""Get information about an exception.
110110
111111
Args:

packages/smithy-core/src/smithy_core/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ClientTimeoutError(CallError):
7575

7676
fault: Fault = "client"
7777
is_timeout_error: bool = True
78-
is_retry_safe: bool = True
78+
is_retry_safe: bool | None = True
7979

8080

8181
class SerializationError(SmithyError):

packages/smithy-http/src/smithy_http/aio/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __post_init__(self) -> None:
5252
class AIOHTTPClient(HTTPClient):
5353
"""Implementation of :py:class:`.interfaces.HTTPClient` using aiohttp."""
5454

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

5858
if isinstance(exception, TimeoutError):

packages/smithy-http/src/smithy_http/aio/crt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient):
136136
_HTTP_PORT = 80
137137
_HTTPS_PORT = 443
138138

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

142142
timeout_indicators = (

packages/smithy-http/tests/unit/aio/test_protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async def test_http_408_creates_timeout_error() -> None:
147147

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

150-
error = await HttpBindingClientProtocol._create_error(
150+
error = await HttpBindingClientProtocol._create_error( # type: ignore[reportPrivateUsage]
151151
protocol,
152152
operation=Mock(),
153153
request=HTTPRequest(

packages/smithy-http/tests/unit/aio/test_timeout_errors.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,68 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
from typing import TYPE_CHECKING
5+
46
import pytest
57
from smithy_core.aio.interfaces import ErrorInfo
68

9+
if TYPE_CHECKING:
10+
from smithy_http.aio.aiohttp import AIOHTTPClient
11+
from smithy_http.aio.crt import AWSCRTHTTPClient
12+
713
try:
814
from smithy_http.aio.aiohttp import AIOHTTPClient
915

10-
HAS_AIOHTTP = True
16+
has_aiohttp = True
1117
except ImportError:
12-
HAS_AIOHTTP = False
18+
has_aiohttp = False
1319

1420
try:
1521
from smithy_http.aio.crt import AWSCRTHTTPClient
1622

17-
HAS_CRT = True
23+
has_crt = True
1824
except ImportError:
19-
HAS_CRT = False
25+
has_crt = False
2026

2127

22-
@pytest.mark.skipif(not HAS_AIOHTTP, reason="aiohttp not available")
28+
@pytest.mark.skipif(not has_aiohttp, reason="aiohttp not available")
2329
class TestAIOHTTPTimeoutErrorHandling:
2430
"""Test timeout error handling for AIOHTTPClient."""
2531

2632
@pytest.fixture
27-
async def client(self):
33+
async def client(self) -> "AIOHTTPClient":
2834
return AIOHTTPClient()
2935

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

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

4450

45-
@pytest.mark.skipif(not HAS_CRT, reason="AWS CRT not available")
51+
@pytest.mark.skipif(not has_crt, reason="AWS CRT not available")
4652
class TestAWSCRTTimeoutErrorHandling:
4753
"""Test timeout error handling for AWSCRTHTTPClient."""
4854

4955
@pytest.fixture
50-
def client(self):
56+
def client(self) -> "AWSCRTHTTPClient":
5157
return AWSCRTHTTPClient()
5258

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

59-
def test_non_timeout_error_detection(self, client):
65+
def test_non_timeout_error_detection(self, client: "AWSCRTHTTPClient") -> None:
6066
"""Test non-timeout error detection."""
6167
other_err = ValueError("Not a timeout")
6268
result = client.get_error_info(other_err)

0 commit comments

Comments
 (0)