Skip to content

Commit f580096

Browse files
Copilot0xrinegade
andcommitted
fix: resolve all flake8 linting issues - line length and unused imports
Co-authored-by: 0xrinegade <[email protected]>
1 parent 319d1f6 commit f580096

File tree

5 files changed

+63
-23
lines changed

5 files changed

+63
-23
lines changed

python/solana_ai_registries/constants.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@
102102
# A2AMPL Token
103103
A2AMPL_DECIMALS: Final[int] = 9
104104
A2AMPL_BASE_UNIT: Final[int] = 1_000_000_000 # 1 A2AMPL = 10^9 base units
105-
A2AMPL_TOKEN_MINT_MAINNET: Final[str] = "Cpzvdx6pppc9TNArsGsqgShCsKC9NCCjA2gtzHvUpump"
106-
A2AMPL_TOKEN_MINT_DEVNET: Final[str] = "A2AMPLyncKHwfSnwRNsJ2qsjsetgo9fGkP8YZPsDZ9mE"
105+
A2AMPL_TOKEN_MINT_MAINNET: Final[str] = (
106+
"Cpzvdx6pppc9TNArsGsqgShCsKC9NCCjA2gtzHvUpump"
107+
)
108+
A2AMPL_TOKEN_MINT_DEVNET: Final[str] = (
109+
"A2AMPLyncKHwfSnwRNsJ2qsjsetgo9fGkP8YZPsDZ9mE"
110+
)
107111

108112
# Agent Registry Fees (in base units)
109113
AGENT_REGISTRATION_FEE: Final[int] = 100_000_000_000 # 100 A2AMPL
@@ -158,7 +162,9 @@
158162
# ============================================================================
159163

160164
# Registry Programs
161-
AGENT_REGISTRY_PROGRAM_ID: Final[str] = "AgentReg11111111111111111111111111111111111"
165+
AGENT_REGISTRY_PROGRAM_ID: Final[str] = (
166+
"AgentReg11111111111111111111111111111111111"
167+
)
162168
MCP_SERVER_REGISTRY_PROGRAM_ID: Final[str] = "TBD" # To be updated
163169

164170
# Authorized External Programs
@@ -232,7 +238,9 @@ def get_token_mint_for_cluster(cluster: str) -> str:
232238
raise ValueError(f"Unsupported cluster: {cluster}")
233239

234240

235-
def validate_string_length(value: str, max_length: int, field_name: str) -> None:
241+
def validate_string_length(
242+
value: str, max_length: int, field_name: str
243+
) -> None:
236244
"""Validate string length against maximum constraint.
237245
238246
Args:
@@ -262,5 +270,6 @@ def validate_url(url: str, field_name: str) -> None:
262270
allowed_schemes = ("http://", "https://", "ipfs://", "ar://")
263271
if not any(url.startswith(scheme) for scheme in allowed_schemes):
264272
raise ValueError(
265-
f"{field_name} must start with one of: {', '.join(allowed_schemes)}"
273+
f"{field_name} must start with one of: "
274+
f"{', '.join(allowed_schemes)}"
266275
)

python/solana_ai_registries/exceptions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def __init__(self, required: int, available: int, token_mint: str):
113113
available: Available amount in base units
114114
token_mint: Token mint address
115115
"""
116-
message = f"Insufficient funds: required {required}, available {available}"
116+
message = (
117+
f"Insufficient funds: required {required}, available {available}"
118+
)
117119
details = {
118120
"required": required,
119121
"available": available,
@@ -171,7 +173,8 @@ def __init__(self, setting: str, value: Any, expected: str):
171173
expected: Description of expected value
172174
"""
173175
message = (
174-
f"Invalid configuration for '{setting}': expected {expected}, got {value}"
176+
f"Invalid configuration for '{setting}': "
177+
f"expected {expected}, got {value}"
175178
)
176179
details = {"setting": setting, "value": value, "expected": expected}
177180
super().__init__(message, details)

python/solana_ai_registries/types.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def __post_init__(self) -> None:
7979
validate_string_length(self.url, 256, "endpoint URL")
8080
validate_url(self.url, "endpoint URL")
8181
if self.description:
82-
validate_string_length(self.description, 512, "endpoint description")
82+
validate_string_length(
83+
self.description, 512, "endpoint description"
84+
)
8385

8486

8587
@dataclass
@@ -146,7 +148,9 @@ def __post_init__(self) -> None:
146148
validate_string_length(self.provider_url, 256, "provider_url")
147149
validate_url(self.provider_url, "provider_url")
148150
if self.documentation_url:
149-
validate_string_length(self.documentation_url, 256, "documentation_url")
151+
validate_string_length(
152+
self.documentation_url, 256, "documentation_url"
153+
)
150154
validate_url(self.documentation_url, "documentation_url")
151155

152156
# Validate collections
@@ -180,7 +184,8 @@ def from_account_data(cls, data: Dict[str, Any]) -> "AgentRegistryEntry":
180184
provider_url=data.get("provider_url"),
181185
documentation_url=data.get("documentation_url"),
182186
service_endpoints=[
183-
ServiceEndpoint(**ep) for ep in data.get("service_endpoints", [])
187+
ServiceEndpoint(**ep)
188+
for ep in data.get("service_endpoints", [])
184189
],
185190
capabilities_flags=data.get("capabilities_flags", 0),
186191
supported_input_modes=data.get("supported_input_modes", []),
@@ -189,7 +194,9 @@ def from_account_data(cls, data: Dict[str, Any]) -> "AgentRegistryEntry":
189194
security_info_uri=data.get("security_info_uri"),
190195
aea_address=data.get("aea_address"),
191196
economic_intent_summary=data.get("economic_intent_summary"),
192-
supported_aea_protocols_hash=data.get("supported_aea_protocols_hash"),
197+
supported_aea_protocols_hash=data.get(
198+
"supported_aea_protocols_hash"
199+
),
193200
extended_metadata_uri=data.get("extended_metadata_uri"),
194201
tags=data.get("tags", []),
195202
created_at=data.get("created_at", 0),
@@ -314,7 +321,9 @@ def __post_init__(self) -> None:
314321
validate_string_length(tag, 32, "server tag")
315322

316323
@classmethod
317-
def from_account_data(cls, data: Dict[str, Any]) -> "McpServerRegistryEntry":
324+
def from_account_data(
325+
cls, data: Dict[str, Any]
326+
) -> "McpServerRegistryEntry":
318327
"""Create instance from on-chain account data.
319328
320329
Args:
@@ -334,8 +343,13 @@ def from_account_data(cls, data: Dict[str, Any]) -> "McpServerRegistryEntry":
334343
resource_count=cap_data.get("resource_count", 0),
335344
prompt_count=cap_data.get("prompt_count", 0),
336345
tools=[McpTool(**tool) for tool in cap_data.get("tools", [])],
337-
resources=[McpResource(**res) for res in cap_data.get("resources", [])],
338-
prompts=[McpPrompt(**prompt) for prompt in cap_data.get("prompts", [])],
346+
resources=[
347+
McpResource(**res) for res in cap_data.get("resources", [])
348+
],
349+
prompts=[
350+
McpPrompt(**prompt)
351+
for prompt in cap_data.get("prompts", [])
352+
],
339353
)
340354

341355
return cls(

python/tests/conftest.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
from solders.pubkey import Pubkey
1515

1616
from solana_ai_registries import SolanaAIRegistriesClient
17-
from solana_ai_registries.constants import DEFAULT_DEVNET_RPC
18-
from solana_ai_registries.types import AgentRegistryEntry, McpServerRegistryEntry
17+
from solana_ai_registries.types import (
18+
AgentRegistryEntry,
19+
McpServerRegistryEntry,
20+
)
1921

2022

2123
@pytest.fixture(scope="session") # type: ignore[misc]
@@ -126,7 +128,9 @@ def mock_mcp_server_data() -> Dict[str, Any]:
126128
"description": "Get current weather for a location",
127129
"tags": ["weather", "current"],
128130
"input_schema": '{"location": "string"}',
129-
"output_schema": '{"temperature": "number", "conditions": "string"}',
131+
"output_schema": (
132+
'{"temperature": "number", "conditions": "string"}'
133+
),
130134
}
131135
],
132136
"resources": [
@@ -164,7 +168,10 @@ def mock_mcp_server_entry(
164168
@pytest.fixture
165169
def mock_transaction_signature() -> str:
166170
"""Mock transaction signature for testing."""
167-
return "5j7XiLkBJbkzCqFbp8XjJ6Ci9k2YfRvB4Y6fJr8bNfQ9YmZrVs8P2V5zQqKpWqGrE8F4TtJzN7YzXvKgRrNfQ2"
171+
return (
172+
"5j7XiLkBJbkzCqFbp8XjJ6Ci9k2YfRvB4Y6fJr8bNfQ9YmZrVs8P2V5zQqKpWqGrE8F4T"
173+
"tJzN7YzXvKgRrNfQ2"
174+
)
168175

169176

170177
@pytest.fixture
@@ -205,7 +212,9 @@ def pytest_configure(config: Any) -> None:
205212
config.addinivalue_line(
206213
"markers", "devnet: tests specifically for devnet environment"
207214
)
208-
config.addinivalue_line("markers", "slow: tests that take longer than 1 second")
215+
config.addinivalue_line(
216+
"markers", "slow: tests that take longer than 1 second"
217+
)
209218

210219

211220
@pytest.fixture(autouse=True)

python/tests/test_imports.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Basic import test to verify the package is correctly installed."""
22

3-
import pytest
4-
53

64
def test_package_imports() -> None:
75
"""Test that all main package components can be imported."""
@@ -18,8 +16,15 @@ def test_package_imports() -> None:
1816
# Type imports
1917
from solana_ai_registries.types import AgentStatus, McpServerStatus
2018

21-
# All imports successful
22-
assert True
19+
# Verify imports by checking they are not None
20+
assert SolanaAIRegistriesClient is not None
21+
assert AgentRegistry is not None
22+
assert McpServerRegistry is not None
23+
assert PaymentManager is not None
24+
assert AGENT_REGISTRY_PROGRAM_ID is not None
25+
assert SolanaAIRegistriesError is not None
26+
assert AgentStatus is not None
27+
assert McpServerStatus is not None
2328

2429

2530
def test_placeholder_classes_exist() -> None:

0 commit comments

Comments
 (0)