Skip to content

Commit 1a5e11e

Browse files
benjibcBenny Chen
andauthored
pyright round 4 (#143)
* pyright round 4 * more fixes * fix more errors --------- Co-authored-by: Benny Chen <bchen@Bennys-MacBook-Air.local>
1 parent 0644511 commit 1a5e11e

File tree

18 files changed

+45
-868
lines changed

18 files changed

+45
-868
lines changed

eval_protocol/benchmarks/test_livebench_data_analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ def _read_jsonl_table_from_text(text: str, header_cols: List[str]):
258258

259259
reader = _read_df_v1 if version == "v1" else _read_df_v2
260260
gt_df = reader(output_fmt, ground_truth)
261+
assert gt_df is not None, "GT dataframe is None"
261262

262263
llm_clean = _clean_llm_output(llm_answer)
263264
llm_clean = _remove_initial_phrase(llm_clean)

eval_protocol/benchmarks/test_tau_bench_airline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def test_tau_bench_airline_evaluation(row: EvaluationRow) -> EvaluationRow:
198198
task = Task(
199199
id="Filler", evaluation_criteria=evaluation_criteria, user_scenario=UserScenario(instructions="Filler")
200200
) # id and user_scenario are required for the Task type but not used in calculating reward
201+
assert task.evaluation_criteria is not None, "Task evaluation criteria is None"
201202

202203
if RewardType.DB in task.evaluation_criteria.reward_basis:
203204
env_reward_info = EnvironmentEvaluator.calculate_reward(

eval_protocol/execution/pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ async def _execute_standard_generation(
212212
if system_prompt_content:
213213
current_messages_for_rollout.append({"role": "system", "content": system_prompt_content})
214214
current_messages_for_rollout.append({"role": "user", "content": user_query})
215+
assert self.model_client is not None, "at this point model client needs to be initialized"
215216

216217
generation_output_std = await self.model_client.generate(
217218
messages=current_messages_for_rollout,

eval_protocol/mcp/client/connection.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import logging
1212
import time
1313
from contextlib import AsyncExitStack
14-
from typing import Any, Dict, List, Optional, Tuple
14+
from typing import Any, Dict, List, Optional, Tuple, cast
1515

1616
import httpx
1717
from mcp.client.session import ClientSession
@@ -276,7 +276,10 @@ async def _get_initial_state_from_mcp_resource(self, session: MCPSession) -> Any
276276
try:
277277
# List available resources - this is where initial state should come from
278278
logger.debug(f"Session {session.session_id}: Discovering MCP resources for initial state...")
279-
resources_response = await mcp_session.list_resources()
279+
mcp_session_local = session._mcp_session
280+
if mcp_session_local is None:
281+
raise RuntimeError("Session not initialized while listing resources")
282+
resources_response = await mcp_session_local.list_resources()
280283
resources = resources_response.resources if hasattr(resources_response, "resources") else []
281284
logger.debug(f"Session {session.session_id}: Found {len(resources)} MCP resources")
282285
for resource in resources:
@@ -303,7 +306,10 @@ async def _get_initial_state_from_mcp_resource(self, session: MCPSession) -> Any
303306
f"Session {session.session_id}: Reading initial state from resource: {initial_state_resource.uri}"
304307
)
305308

306-
resource_content = await mcp_session.read_resource(initial_state_resource.uri)
309+
mcp_session_for_read = session._mcp_session
310+
if mcp_session_for_read is None:
311+
raise RuntimeError("Session not initialized while reading resource")
312+
resource_content = await mcp_session_for_read.read_resource(initial_state_resource.uri)
307313

308314
# Handle the new ResourceContents format
309315
text_value = getattr(resource_content, "text", None)
@@ -348,7 +354,10 @@ async def _get_initial_state_from_mcp_resource(self, session: MCPSession) -> Any
348354
f"Session {session.session_id}: About to call mcp_session.read_resource with fallback URI: {first_resource.uri}"
349355
)
350356

351-
resource_content = await mcp_session.read_resource(first_resource.uri)
357+
mcp_session_for_fallback_read = session._mcp_session
358+
if mcp_session_for_fallback_read is None:
359+
raise RuntimeError("Session not initialized while reading fallback resource")
360+
resource_content = await mcp_session_for_fallback_read.read_resource(first_resource.uri)
352361

353362
logger.debug(
354363
f"Session {session.session_id}: fallback read_resource returned type: {type(resource_content)}"

eval_protocol/mcp_agent/intermediary_server.py

Lines changed: 0 additions & 541 deletions
This file was deleted.

eval_protocol/mcp_agent/orchestration/remote_http_client.py

Lines changed: 0 additions & 307 deletions
This file was deleted.

0 commit comments

Comments
 (0)