bshepp commited on
Commit
0fe4d92
Β·
1 Parent(s): 5d53fbf

fix: resolve 13 Pylance type-checking warnings

Browse files

- test_e2e.py: initialize steps/result before polling loop to avoid possibly-unbound
- test_rag_quality.py: add assert _collection is not None after initialization (3 sites)
- validation/base.py: filename param typed Optional[str] instead of str
- validation/run_validation.py: capture getenv result to avoid str|None assignment

src/backend/test_e2e.py CHANGED
@@ -25,6 +25,8 @@ async def main():
25
  print(f"Submitted case: {case_id}")
26
 
27
  # Poll until done
 
 
28
  for i in range(60): # up to 5 minutes
29
  await asyncio.sleep(5)
30
  r = await client.get(f"{API}/api/cases/{case_id}")
 
25
  print(f"Submitted case: {case_id}")
26
 
27
  # Poll until done
28
+ steps: list = []
29
+ result: dict = {}
30
  for i in range(60): # up to 5 minutes
31
  await asyncio.sleep(5)
32
  r = await client.get(f"{API}/api/cases/{case_id}")
src/backend/test_rag_quality.py CHANGED
@@ -242,6 +242,7 @@ async def rebuild_chroma(persist_dir: str):
242
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
243
  tool = GuidelineRetrievalTool()
244
  await tool._ensure_initialized()
 
245
  count = tool._collection.count()
246
  print(f" Rebuilt collection with {count} guidelines")
247
  return tool
@@ -252,6 +253,7 @@ async def show_stats(persist_dir: str):
252
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
253
  tool = GuidelineRetrievalTool()
254
  await tool._ensure_initialized()
 
255
 
256
  count = tool._collection.count()
257
  print(f"\n Collection: clinical_guidelines")
@@ -371,6 +373,7 @@ async def main():
371
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
372
  tool = GuidelineRetrievalTool()
373
  await tool._ensure_initialized()
 
374
  count = tool._collection.count()
375
  print(f"\n Collection has {count} documents")
376
  if count == 0:
 
242
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
243
  tool = GuidelineRetrievalTool()
244
  await tool._ensure_initialized()
245
+ assert tool._collection is not None, "Collection failed to initialize"
246
  count = tool._collection.count()
247
  print(f" Rebuilt collection with {count} guidelines")
248
  return tool
 
253
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
254
  tool = GuidelineRetrievalTool()
255
  await tool._ensure_initialized()
256
+ assert tool._collection is not None, "Collection failed to initialize"
257
 
258
  count = tool._collection.count()
259
  print(f"\n Collection: clinical_guidelines")
 
373
  from app.tools.guideline_retrieval import GuidelineRetrievalTool
374
  tool = GuidelineRetrievalTool()
375
  await tool._ensure_initialized()
376
+ assert tool._collection is not None, "Collection failed to initialize"
377
  count = tool._collection.count()
378
  print(f"\n Collection has {count} documents")
379
  if count == 0:
src/backend/validation/base.py CHANGED
@@ -297,7 +297,7 @@ def clear_checkpoint(dataset: str) -> None:
297
  # Final results save
298
  # ──────────────────────────────────────────────
299
 
300
- def save_results(summary: ValidationSummary, filename: str = None):
301
  """Save validation results to JSON."""
302
  RESULTS_DIR.mkdir(parents=True, exist_ok=True)
303
 
 
297
  # Final results save
298
  # ──────────────────────────────────────────────
299
 
300
+ def save_results(summary: ValidationSummary, filename: Optional[str] = None):
301
  """Save validation results to JSON."""
302
  RESULTS_DIR.mkdir(parents=True, exist_ok=True)
303
 
src/backend/validation/run_validation.py CHANGED
@@ -32,8 +32,9 @@ if str(BACKEND_DIR) not in sys.path:
32
  # Load .env and export HF_TOKEN so huggingface_hub picks it up
33
  from dotenv import load_dotenv
34
  load_dotenv(BACKEND_DIR / ".env")
35
- if os.getenv("HF_TOKEN"):
36
- os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
 
37
 
38
  from validation.base import (
39
  ValidationSummary,
 
32
  # Load .env and export HF_TOKEN so huggingface_hub picks it up
33
  from dotenv import load_dotenv
34
  load_dotenv(BACKEND_DIR / ".env")
35
+ hf_token = os.getenv("HF_TOKEN")
36
+ if hf_token:
37
+ os.environ["HF_TOKEN"] = hf_token
38
 
39
  from validation.base import (
40
  ValidationSummary,