Skip to content

Commit 55b0595

Browse files
codebydivineclaude
andcommitted
fix: Resolve major mypy type issues and update divine-requests to 0.1.10
- Remove data field from BaseResponse to fix TypedDict field overwriting - Add generic type variables to convert functions for better type safety - Update divine-requests dependency to 0.1.10 - Bump version to 0.1.12 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 28a2e73 commit 55b0595

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "divine-thegraph-token-api"
7-
version = "0.1.11"
7+
version = "0.1.12"
88
authors = [
99
{ name="DIVINE", email="[email protected]" },
1010
]
@@ -26,7 +26,7 @@ classifiers = [
2626
]
2727
keywords = ["blockchain", "ethereum", "solana", "defi", "nft", "api", "thegraph", "web3", "crypto"]
2828
dependencies = [
29-
"divine-requests==0.1.4",
29+
"divine-requests==0.1.10",
3030
"divine-type-enforcer==0.1.4",
3131
"anyio>=4.0.0",
3232
]

src/thegraph_token_api/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
import inspect
1111
from dataclasses import dataclass
12+
from typing import TypeVar
13+
14+
T = TypeVar('T', bound='BaseModel')
1215

1316

1417
@dataclass
@@ -306,7 +309,7 @@ class OHLC(BaseModel):
306309
transactions: float
307310

308311

309-
def convert_to_model(data: dict, model_class) -> BaseModel:
312+
def convert_to_model(data: dict, model_class: type[T]) -> T | None:
310313
"""Convert dictionary data to structured model."""
311314
if not data:
312315
return None
@@ -356,6 +359,6 @@ def convert_to_model(data: dict, model_class) -> BaseModel:
356359
return model_class(**working_data)
357360

358361

359-
def convert_list_to_models(data_list: list[dict], model_class) -> list[BaseModel]:
362+
def convert_list_to_models(data_list: list[dict], model_class: type[T]) -> list[T]:
360363
"""Convert list of dictionaries to list of structured models."""
361-
return [convert_to_model(item, model_class) for item in data_list if item]
364+
return [model for item in data_list if item and (model := convert_to_model(item, model_class)) is not None]

src/thegraph_token_api/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class BaseResponse(TypedDict, total=False):
1515
"""Base response structure for all API endpoints."""
1616

17-
data: list[dict]
1817
results: int | None # Number of results returned
1918
statistics: dict | None
2019
duration_ms: float | None

0 commit comments

Comments
 (0)