Skip to content

Commit 8237078

Browse files
authored
Revert "chore(core): make ty the default typechecker (#736)"
This reverts commit 052545b.
1 parent 052545b commit 8237078

File tree

89 files changed

+559
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+559
-1004
lines changed

justfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,13 @@ lint: fix
170170
fix:
171171
uv run ruff check --fix --unsafe-fixes src tests test-int
172172

173-
# Type check code (ty)
174-
typecheck:
175-
uv run ty check src tests test-int
176-
177173
# Type check code (pyright)
178-
typecheck-pyright:
174+
typecheck:
179175
uv run pyright
180176

181177
# Type check code (ty)
182178
typecheck-ty:
183-
just typecheck
179+
uv run ty check src/
184180

185181
# Clean build artifacts and cache files
186182
clean:

src/basic_memory/api/v2/routers/prompt_router.py

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from datetime import datetime, timezone
9-
from typing import Any
109
from fastapi import APIRouter, HTTPException, status, Path
1110
from loguru import logger
1211

@@ -60,7 +59,6 @@ async def continue_conversation(
6059

6160
# Initialize search results
6261
search_results = []
63-
hierarchical_results_for_count = []
6462

6563
# Get data needed for template
6664
if request.topic:
@@ -93,8 +91,7 @@ async def continue_conversation(
9391
# Limit to a reasonable number of total results
9492
all_hierarchical_results = all_hierarchical_results[:10]
9593

96-
hierarchical_results_for_count = all_hierarchical_results
97-
template_context: dict[str, Any] = {
94+
template_context = {
9895
"topic": request.topic,
9996
"timeframe": request.timeframe,
10097
"hierarchical_results": all_hierarchical_results,
@@ -113,7 +110,6 @@ async def continue_conversation(
113110

114111
hierarchical_results = recent_context.results[:5] # Limit to top 5 recent items
115112

116-
hierarchical_results_for_count = hierarchical_results
117113
template_context = {
118114
"topic": f"Recent Activity from ({request.timeframe})",
119115
"timeframe": request.timeframe,
@@ -133,6 +129,9 @@ async def continue_conversation(
133129
relation_count = 0
134130
entity_count = 0
135131

132+
# Get the hierarchical results from the template context
133+
hierarchical_results_for_count = template_context.get("hierarchical_results", [])
134+
136135
# For topic-based search
137136
if request.topic:
138137
for item in hierarchical_results_for_count:
@@ -160,24 +159,29 @@ async def continue_conversation(
160159
elif related.type == "entity": # pragma: no cover
161160
entity_count += 1 # pragma: no cover
162161

163-
prompt_metadata = PromptMetadata(
164-
query=request.topic,
165-
timeframe=request.timeframe,
166-
search_count=len(search_results) if request.topic else 0,
167-
context_count=len(hierarchical_results_for_count),
168-
observation_count=observation_count,
169-
relation_count=relation_count,
170-
total_items=(
162+
# Build metadata
163+
metadata = {
164+
"query": request.topic,
165+
"timeframe": request.timeframe,
166+
"search_count": len(search_results)
167+
if request.topic
168+
else 0, # Original search results count
169+
"context_count": len(hierarchical_results_for_count),
170+
"observation_count": observation_count,
171+
"relation_count": relation_count,
172+
"total_items": (
171173
len(hierarchical_results_for_count)
172174
+ observation_count
173175
+ relation_count
174176
+ entity_count
175177
),
176-
search_limit=request.search_items_limit,
177-
context_depth=request.depth,
178-
related_limit=request.related_items_limit,
179-
generated_at=datetime.now(timezone.utc).isoformat(),
180-
)
178+
"search_limit": request.search_items_limit,
179+
"context_depth": request.depth,
180+
"related_limit": request.related_items_limit,
181+
"generated_at": datetime.now(timezone.utc).isoformat(),
182+
}
183+
184+
prompt_metadata = PromptMetadata(**metadata)
181185

182186
return PromptResponse(
183187
prompt=rendered_prompt, context=template_context, metadata=prompt_metadata
@@ -225,7 +229,7 @@ async def search_prompt(
225229
results = await search_service.search(query, limit=limit, offset=offset)
226230
search_results = await to_search_results(entity_service, results)
227231

228-
template_context: dict[str, Any] = {
232+
template_context = {
229233
"query": request.query,
230234
"timeframe": request.timeframe,
231235
"results": search_results,
@@ -237,19 +241,22 @@ async def search_prompt(
237241
# Render template
238242
rendered_prompt = await template_loader.render("prompts/search.hbs", template_context)
239243

240-
prompt_metadata = PromptMetadata(
241-
query=request.query,
242-
timeframe=request.timeframe,
243-
search_count=len(search_results),
244-
context_count=len(search_results),
245-
observation_count=0,
246-
relation_count=0,
247-
total_items=len(search_results),
248-
search_limit=limit,
249-
context_depth=0,
250-
related_limit=0,
251-
generated_at=datetime.now(timezone.utc).isoformat(),
252-
)
244+
# Build metadata
245+
metadata = {
246+
"query": request.query,
247+
"timeframe": request.timeframe,
248+
"search_count": len(search_results),
249+
"context_count": len(search_results),
250+
"observation_count": 0, # Search results don't include observations
251+
"relation_count": 0, # Search results don't include relations
252+
"total_items": len(search_results),
253+
"search_limit": limit,
254+
"context_depth": 0, # No context depth for basic search
255+
"related_limit": 0, # No related items for basic search
256+
"generated_at": datetime.now(timezone.utc).isoformat(),
257+
}
258+
259+
prompt_metadata = PromptMetadata(**metadata)
253260

254261
return PromptResponse(
255262
prompt=rendered_prompt, context=template_context, metadata=prompt_metadata

src/basic_memory/api/v2/routers/resource_router.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ async def create_resource(
211211
action="create",
212212
phase="search_index",
213213
):
214-
await search_service.index_entity(entity)
214+
await search_service.index_entity(entity) # pyright: ignore
215215

216216
return ResourceResponse(
217217
entity_id=entity.id,
@@ -326,16 +326,14 @@ async def update_resource(
326326
"updated_at": file_metadata.modified_at,
327327
},
328328
)
329-
if updated_entity is None:
330-
raise HTTPException(status_code=404, detail=f"Entity {entity_id} not found")
331329

332330
with telemetry.scope(
333331
"api.resource.update.search_index",
334332
domain="resource",
335333
action="update",
336334
phase="search_index",
337335
):
338-
await search_service.index_entity(updated_entity)
336+
await search_service.index_entity(updated_entity) # pyright: ignore
339337

340338
return ResourceResponse(
341339
entity_id=entity.id,

0 commit comments

Comments
 (0)