Skip to content

Commit 7c17473

Browse files
Copilot0xrinegade
andcommitted
fix: resolve all mypy type annotation errors in Python SDK
Co-authored-by: 0xrinegade <[email protected]>
1 parent b765d37 commit 7c17473

File tree

5 files changed

+37
-21
lines changed

5 files changed

+37
-21
lines changed

python/mypy.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[mypy]
2+
python_version = 3.12
3+
warn_return_any = True
4+
warn_unused_configs = True
5+
disallow_untyped_defs = True
6+
disallow_incomplete_defs = True
7+
check_untyped_defs = True
8+
disallow_untyped_decorators = True
9+
exclude = tests/
10+
11+
# Ignore missing imports for test dependencies and external packages
12+
[mypy-pytest.*]
13+
ignore_missing_imports = True
14+
15+
[mypy-solders.*]
16+
ignore_missing_imports = True

python/solana_ai_registries/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
providing clear error messages and proper inheritance hierarchy.
66
"""
77

8-
from typing import Any, Dict, Optional
8+
from typing import Any, Dict, List, Optional
99

1010

1111
class SolanaAIRegistriesError(Exception):
@@ -46,7 +46,7 @@ class TransactionError(SolanaAIRegistriesError):
4646
"""Raised when a Solana transaction fails."""
4747

4848
def __init__(
49-
self, message: str, signature: Optional[str] = None, logs: Optional[list] = None
49+
self, message: str, signature: Optional[str] = None, logs: Optional[List[str]] = None
5050
):
5151
"""Initialize transaction error.
5252
@@ -55,7 +55,7 @@ def __init__(
5555
signature: Transaction signature if available
5656
logs: Transaction logs if available
5757
"""
58-
details = {}
58+
details: Dict[str, Any] = {}
5959
if signature:
6060
details["signature"] = signature
6161
if logs:

python/solana_ai_registries/types.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ServiceEndpoint:
7373
url: str
7474
description: Optional[str] = None
7575

76-
def __post_init__(self):
76+
def __post_init__(self) -> None:
7777
"""Validate endpoint data after initialization."""
7878
validate_string_length(self.protocol, 64, "protocol")
7979
validate_string_length(self.url, 256, "endpoint URL")
@@ -91,7 +91,7 @@ class AgentSkill:
9191
tags: List[str] = field(default_factory=list)
9292
metadata: Optional[Dict[str, Any]] = None
9393

94-
def __post_init__(self):
94+
def __post_init__(self) -> None:
9595
"""Validate skill data after initialization."""
9696
validate_string_length(self.skill_id, 64, "skill ID")
9797
validate_string_length(self.name, 128, "skill name")
@@ -129,7 +129,7 @@ class AgentRegistryEntry:
129129
updated_at: int = 0
130130
state_version: int = 1
131131

132-
def __post_init__(self):
132+
def __post_init__(self) -> None:
133133
"""Validate agent data after initialization."""
134134
# Validate required fields
135135
validate_string_length(self.agent_id, MAX_AGENT_ID_LEN, "agent_id")
@@ -213,7 +213,7 @@ class McpTool:
213213
input_schema: Optional[str] = None
214214
output_schema: Optional[str] = None
215215

216-
def __post_init__(self):
216+
def __post_init__(self) -> None:
217217
"""Validate tool data after initialization."""
218218
validate_string_length(self.name, 64, "tool name")
219219
if len(self.tags) > 3:
@@ -231,7 +231,7 @@ class McpResource:
231231
description: Optional[str] = None
232232
tags: List[str] = field(default_factory=list)
233233

234-
def __post_init__(self):
234+
def __post_init__(self) -> None:
235235
"""Validate resource data after initialization."""
236236
validate_string_length(self.uri_pattern, 128, "URI pattern")
237237
if len(self.tags) > 3:
@@ -248,7 +248,7 @@ class McpPrompt:
248248
description: Optional[str] = None
249249
tags: List[str] = field(default_factory=list)
250250

251-
def __post_init__(self):
251+
def __post_init__(self) -> None:
252252
"""Validate prompt data after initialization."""
253253
validate_string_length(self.name, 64, "prompt name")
254254
if len(self.tags) > 3:
@@ -290,7 +290,7 @@ class McpServerRegistryEntry:
290290
updated_at: int = 0
291291
state_version: int = 1
292292

293-
def __post_init__(self):
293+
def __post_init__(self) -> None:
294294
"""Validate MCP server data after initialization."""
295295
validate_string_length(self.server_id, MAX_SERVER_ID_LEN, "server_id")
296296
validate_string_length(self.name, MAX_SERVER_NAME_LEN, "name")

python/tests/conftest.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from solana_ai_registries.types import AgentRegistryEntry, McpServerRegistryEntry
1919

2020

21-
@pytest.fixture(scope="session")
22-
def event_loop():
21+
@pytest.fixture(scope="session") # type: ignore[misc]
22+
def event_loop() -> Any:
2323
"""Create an instance of the default event loop for the test session."""
2424
loop = asyncio.get_event_loop_policy().new_event_loop()
2525
yield loop
@@ -53,10 +53,10 @@ def mock_client() -> Mock:
5353
@pytest.fixture
5454
async def devnet_client() -> AsyncGenerator[SolanaAIRegistriesClient, None]:
5555
"""Create a real client connected to devnet for integration tests."""
56-
client = SolanaAIRegistriesClient(DEFAULT_DEVNET_RPC)
56+
client = SolanaAIRegistriesClient()
5757
yield client
58-
# Cleanup if needed
59-
await client.close()
58+
# Cleanup if needed - client currently has no close method
59+
# await client.close()
6060

6161

6262
@pytest.fixture
@@ -194,7 +194,7 @@ def mock_token_balance() -> Dict[str, Any]:
194194
pytest_plugins = ["pytest_asyncio"]
195195

196196

197-
def pytest_configure(config):
197+
def pytest_configure(config: Any) -> None:
198198
"""Configure pytest with custom markers."""
199199
config.addinivalue_line(
200200
"markers", "unit: fast unit tests that don't require network"
@@ -209,22 +209,22 @@ def pytest_configure(config):
209209

210210

211211
@pytest.fixture(autouse=True)
212-
def reset_environment_variables(monkeypatch):
212+
def reset_environment_variables(monkeypatch: Any) -> None:
213213
"""Reset environment variables for each test."""
214214
# Clear any environment variables that might affect tests
215215
monkeypatch.delenv("SOLANA_RPC_URL", raising=False)
216216
monkeypatch.delenv("A2AMPL_TOKEN_MINT", raising=False)
217217

218218

219219
# Helper functions for tests
220-
def assert_valid_signature(signature: str):
220+
def assert_valid_signature(signature: str) -> None:
221221
"""Assert that a signature is valid format."""
222222
assert isinstance(signature, str)
223223
assert len(signature) >= 87 # Minimum length for base58 signature
224224
assert len(signature) <= 88 # Maximum length for base58 signature
225225

226226

227-
def assert_valid_pubkey(pubkey: str):
227+
def assert_valid_pubkey(pubkey: str) -> None:
228228
"""Assert that a public key is valid format."""
229229
assert isinstance(pubkey, str)
230230
assert len(pubkey) == 44 # Standard length for base58 public key

python/tests/test_imports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55

6-
def test_package_imports():
6+
def test_package_imports() -> None:
77
"""Test that all main package components can be imported."""
88
# Core imports
99
from solana_ai_registries import (
@@ -22,7 +22,7 @@ def test_package_imports():
2222
assert True
2323

2424

25-
def test_placeholder_classes_exist():
25+
def test_placeholder_classes_exist() -> None:
2626
"""Test that placeholder classes are instantiable."""
2727
from solana_ai_registries import (
2828
AgentRegistry,

0 commit comments

Comments
 (0)