Skip to content

Commit 368f06a

Browse files
committed
fix: resolve mypy type errors
1 parent 99f68aa commit 368f06a

5 files changed

Lines changed: 33 additions & 30 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ asyncio_mode = "auto"
5858
addopts = "--cov=stableops --cov-report=term-missing --cov-report=html"
5959

6060
[tool.mypy]
61-
python_version = "3.8"
61+
python_version = "3.10"
6262
strict = true
6363
warn_return_any = true
6464
warn_unused_configs = true

stableops/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""StableOps client."""
22

3-
from typing import Optional
3+
from typing import Any, Optional
44

55
from stableops.addresses import AddressesApi, AsyncAddressesApi
66
from stableops.checkout_sessions import AsyncCheckoutSessionsApi, CheckoutSessionsApi
@@ -68,7 +68,7 @@ def __enter__(self) -> "StableOps":
6868
"""Context manager entry."""
6969
return self
7070

71-
def __exit__(self, *args) -> None:
71+
def __exit__(self, *args: Any) -> None:
7272
"""Context manager exit."""
7373
self.close()
7474

@@ -132,6 +132,6 @@ async def __aenter__(self) -> "AsyncStableOps":
132132
"""Async context manager entry."""
133133
return self
134134

135-
async def __aexit__(self, *args) -> None:
135+
async def __aexit__(self, *args: Any) -> None:
136136
"""Async context manager exit."""
137137
await self.close()

stableops/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def request(
304304
def _parse_error(self, response: httpx.Response) -> Dict[str, Any]:
305305
"""Parse error response."""
306306
try:
307-
return response.json()
307+
return response.json() # type: ignore[no-any-return]
308308
except Exception:
309309
return {"message": response.text or "Unknown error", "code": "unknown_error"}
310310

@@ -501,7 +501,7 @@ async def request(
501501
def _parse_error(self, response: httpx.Response) -> Dict[str, Any]:
502502
"""Parse error response."""
503503
try:
504-
return response.json()
504+
return response.json() # type: ignore[no-any-return]
505505
except Exception:
506506
return {"message": response.text or "Unknown error", "code": "unknown_error"}
507507

tests/test_types.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
from typing import get_args
44

5-
from stableops.types import ChainId, PaymentOrder, PaymentOrderStatus
5+
from stableops.types import (
6+
AcceptedAssetInput,
7+
ChainId,
8+
PaymentOrder,
9+
PaymentOrderInstruction,
10+
PaymentOrderStatus,
11+
)
612

713

8-
def test_type_aliases_match_current_api_contract():
14+
def test_type_aliases_match_current_api_contract() -> None:
915
"""Public Literal aliases should expose the same enum values as the API."""
1016
assert "solana" in get_args(ChainId)
1117
assert "optimism" in get_args(ChainId)
@@ -15,7 +21,7 @@ def test_type_aliases_match_current_api_contract():
1521
assert "CREATED" not in get_args(PaymentOrderStatus)
1622

1723

18-
def test_payment_order_accepts_current_api_wire_values():
24+
def test_payment_order_accepts_current_api_wire_values() -> None:
1925
"""Python SDK types should match values returned by the API."""
2026
order = PaymentOrder(
2127
id="po_123",
@@ -26,13 +32,9 @@ def test_payment_order_accepts_current_api_wire_values():
2632
expires_at=None,
2733
metadata=None,
2834
created_at="2026-05-31T00:00:00.000Z",
29-
accepted_assets=[{"chain": "solana", "asset": "USDC"}],
35+
accepted_assets=[AcceptedAssetInput(chain="solana", asset="USDC")],
3036
payment_instructions=[
31-
{
32-
"chain": "solana",
33-
"asset": "USDC",
34-
"address": "RecipientWallet123",
35-
}
37+
PaymentOrderInstruction(chain="solana", asset="USDC", address="RecipientWallet123")
3638
],
3739
)
3840

tests/test_webhooks.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import hashlib
44
import hmac
5+
from typing import Any
56

67
from stableops.webhooks import (
78
SIGNATURE_HEADER,
@@ -24,11 +25,11 @@ def build_header(secret: str, timestamp: int, body: str) -> str:
2425
return f"t={timestamp},v1={signature}"
2526

2627

27-
def test_signature_header_constant_matches_delivery_protocol():
28+
def test_signature_header_constant_matches_delivery_protocol() -> None:
2829
assert SIGNATURE_HEADER == "x-product-signature"
2930

3031

31-
def test_valid_signature_header():
32+
def test_valid_signature_header() -> None:
3233
secret = "whsec_test123"
3334
body = '{"type":"payment.finalized","data":{"payment_order_id":"po_123"}}'
3435

@@ -43,7 +44,7 @@ def test_valid_signature_header():
4344
assert result.reason == "valid"
4445

4546

46-
def test_accepts_any_v1_signature_during_rotation():
47+
def test_accepts_any_v1_signature_during_rotation() -> None:
4748
old_secret = "whsec_old"
4849
new_secret = "whsec_new"
4950
body = '{"type":"payment.finalized"}'
@@ -63,7 +64,7 @@ def test_accepts_any_v1_signature_during_rotation():
6364
assert result.reason == "valid"
6465

6566

66-
def test_invalid_signature():
67+
def test_invalid_signature() -> None:
6768
result = verify_webhook_signature(
6869
body='{"type":"payment.finalized"}',
6970
header=f"t={NOW},v1=invalid_signature",
@@ -75,7 +76,7 @@ def test_invalid_signature():
7576
assert result.reason == "invalid_signature"
7677

7778

78-
def test_missing_header():
79+
def test_missing_header() -> None:
7980
result = verify_webhook_signature(
8081
body='{"type":"payment.finalized"}',
8182
header="",
@@ -87,7 +88,7 @@ def test_missing_header():
8788
assert result.reason == "missing_header"
8889

8990

90-
def test_timestamp_too_old():
91+
def test_timestamp_too_old() -> None:
9192
result = verify_webhook_signature(
9293
body='{"type":"payment.finalized"}',
9394
header=f"t={NOW},v1=sig123",
@@ -100,7 +101,7 @@ def test_timestamp_too_old():
100101
assert result.reason == "timestamp_expired"
101102

102103

103-
def test_invalid_header_format():
104+
def test_invalid_header_format() -> None:
104105
result = verify_webhook_signature(
105106
body='{"type":"payment.finalized"}',
106107
header="t=not_a_number,v1=sig123",
@@ -112,30 +113,30 @@ def test_invalid_header_format():
112113
assert result.reason == "invalid_format"
113114

114115

115-
def test_webhooks_api_matches_server_routes():
116+
def test_webhooks_api_matches_server_routes() -> None:
116117
assert not hasattr(WebhooksApi, "retrieve")
117118
assert not hasattr(WebhooksApi, "delete")
118119
assert not hasattr(AsyncWebhooksApi, "retrieve")
119120
assert not hasattr(AsyncWebhooksApi, "delete")
120121

121122

122-
def test_webhooks_api_exposes_delivery_and_replay_methods():
123+
def test_webhooks_api_exposes_delivery_and_replay_methods() -> None:
123124
for name in ("replay", "list_deliveries", "replay_delivery", "replay_dead_letters"):
124125
assert hasattr(WebhooksApi, name)
125126
assert hasattr(AsyncWebhooksApi, name)
126127

127128

128129
class _FakeHttp:
129-
def __init__(self, response):
130+
def __init__(self, response: Any) -> None:
130131
self.response = response
131-
self.last_request = {}
132+
self.last_request: dict[str, Any] = {}
132133

133-
def request(self, **kwargs):
134+
def request(self, **kwargs: Any) -> Any:
134135
self.last_request = kwargs
135136
return self.response
136137

137138

138-
def test_create_endpoint_forwards_redact_metadata():
139+
def test_create_endpoint_forwards_redact_metadata() -> None:
139140
http = _FakeHttp(
140141
{
141142
"id": "we_1",
@@ -159,7 +160,7 @@ def test_create_endpoint_forwards_redact_metadata():
159160
assert endpoint.redact_metadata is True
160161

161162

162-
def test_list_deliveries_filters_and_parses():
163+
def test_list_deliveries_filters_and_parses() -> None:
163164
http = _FakeHttp(
164165
{
165166
"items": [
@@ -198,7 +199,7 @@ def test_list_deliveries_filters_and_parses():
198199
assert deliveries[0].payload == {"type": "payment.finalized"}
199200

200201

201-
def test_replay_dead_letters_parses_result():
202+
def test_replay_dead_letters_parses_result() -> None:
202203
http = _FakeHttp(
203204
{
204205
"replayed": 2,

0 commit comments

Comments
 (0)