fix: resolve all invalid-return-type ty diagnostics across codebase

Widen return type annotations to match actual control flow, add
unreachable assertions after retry loops ty cannot prove terminate,
split ambiguous union returns (auth.py credential pool), and remove
the AIOHTTP_AVAILABLE conditional-import guard from api_server.py.
This commit is contained in:
alt-glitch 2026-04-21 14:55:09 +05:30
parent 432614591a
commit 4a95029e6c
23 changed files with 102 additions and 103 deletions

View file

@ -37,7 +37,7 @@ import yaml
import logging
import asyncio
from pathlib import Path
from typing import List, Dict, Any, Optional, Tuple, Callable
from typing import List, Dict, Any, Optional, Tuple, Callable, cast
from dataclasses import dataclass, field
from datetime import datetime
@ -75,7 +75,7 @@ def _effective_temperature_for_model(
if fixed_temperature is OMIT_TEMPERATURE:
return None # caller must omit temperature
if fixed_temperature is not None:
return fixed_temperature
return cast(float, fixed_temperature)
return requested_temperature
@ -636,7 +636,8 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
else:
# Fallback: create a basic summary
return "[CONTEXT SUMMARY]: [Summary generation failed - previous turns contained tool calls and responses that have been compressed to save context space.]"
raise AssertionError("unreachable: retry loop exhausted")
async def _generate_summary_async(self, content: str, metrics: TrajectoryMetrics) -> str:
"""
Generate a summary of the compressed turns using OpenRouter (async version).
@ -705,7 +706,8 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
else:
# Fallback: create a basic summary
return "[CONTEXT SUMMARY]: [Summary generation failed - previous turns contained tool calls and responses that have been compressed to save context space.]"
raise AssertionError("unreachable: retry loop exhausted")
def compress_trajectory(
self,
trajectory: List[Dict[str, str]]