Skip to content

Commit 4fbab24

Browse files
committed
fixed typing issue
1 parent 2384db6 commit 4fbab24

4 files changed

Lines changed: 30 additions & 21 deletions

File tree

examples/introduction/tutorial.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"\n",
1010
"[![Open Notebook on GitHub](https://img.shields.io/badge/Open%20Notebook%20on-GitHub-blue?logo=github)](https://github.com/parameterlab/MASEval/blob/main/examples/introduction/tutorial.ipynb)\n",
1111
"\n",
12-
"This notebook is available as a Jupyter notebook clone the repo and run it yourself!\n",
12+
"This notebook is available as a Jupyter notebook \u2014 clone the repo and run it yourself!\n",
1313
"\n",
1414
"## What You'll Learn\n",
1515
"\n",
16-
"- **Build your first agent** Create tools and agents with smolagents\n",
17-
"- **Run a minimal benchmark** One task, one agent, end-to-end\n",
18-
"- **Understand the core abstractions** Tasks, Environments, Evaluators working together\n",
16+
"- **Build your first agent** \u2014 Create tools and agents with smolagents\n",
17+
"- **Run a minimal benchmark** \u2014 One task, one agent, end-to-end\n",
18+
"- **Understand the core abstractions** \u2014 Tasks, Environments, Evaluators working together\n",
1919
"\n",
2020
"\n",
2121
"This tutorial first introduces [`smolagents`](https://huggingface.co/docs/smolagents/en/index) as introduction to agents. Then it provides a super small single task benchmark."
@@ -634,13 +634,13 @@
634634
"metadata": {},
635635
"outputs": [],
636636
"source": [
637-
"\"# Create benchmark instance with agent configuration\\n\",\n",
638-
" \"agent_data = {\\\"model_id\\\": \\\"gemini/gemini-2.5-flash\\\", \\\"temperature\\\": 0.7}\\n\",\n",
639-
" \"\\n\",\n",
640-
" \"benchmark = SimpleBenchmark(agent_data=agent_data, progress_bar=False)\\n\",\n",
641-
" \"\\n\",\n",
642-
" \"# Create task queue\\n\",\n",
643-
" \"tasks = TaskQueue([task])\\n\",\n",
637+
"# Create benchmark instance with agent configuration\n",
638+
"agent_data = {\"model_id\": \"gemini/gemini-2.5-flash\", \"temperature\": 0.7}\n",
639+
"\n",
640+
"benchmark = SimpleBenchmark(agent_data=agent_data, progress_bar=False)\n",
641+
"\n",
642+
"# Create task queue\n",
643+
"tasks = TaskQueue([task])\n",
644644
"\n",
645645
"# Run the benchmark\n",
646646
"print(\"Running benchmark...\\n\")\n",
@@ -715,7 +715,7 @@
715715
"\n",
716716
"## Next Steps\n",
717717
"\n",
718-
"1. **Try the Five-A-Day Benchmark notebook** A production-ready example with multi-agent systems and diverse evaluators\n",
718+
"1. **Try the Five-A-Day Benchmark notebook** \u2014 A production-ready example with multi-agent systems and diverse evaluators\n",
719719
"2. Create your own custom evaluators for your specific use case\n",
720720
"3. Experiment with different agent frameworks (LangGraph, LlamaIndex)\n",
721721
"4. Add callbacks for logging and tracing\n",
@@ -745,4 +745,4 @@
745745
},
746746
"nbformat": 4,
747747
"nbformat_minor": 5
748-
}
748+
}

maseval/core/task.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABC, abstractmethod
22
from dataclasses import dataclass, field
3-
from typing import Any, Dict, Tuple
3+
from typing import Any, Dict, Tuple, overload
44
from uuid import UUID, uuid4
55
from collections.abc import Sequence
66
from typing import Iterable, List, Union, Iterator, Optional
@@ -108,6 +108,12 @@ def __len__(self) -> int:
108108
"""Return the total number of tasks in the queue."""
109109
return len(self._tasks)
110110

111+
@overload
112+
def __getitem__(self, idx: int) -> Task: ...
113+
114+
@overload
115+
def __getitem__(self, idx: slice) -> "BaseTaskQueue": ...
116+
111117
def __getitem__(self, idx: Union[int, slice]) -> Union[Task, "BaseTaskQueue"]:
112118
"""Get a task by index or a slice of tasks.
113119

tests/test_core/test_context.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def test_check_timeout_raises_on_expiry(self):
7979
with pytest.raises(TaskTimeoutError) as exc_info:
8080
context.check_timeout()
8181

82-
assert exc_info.value.timeout == 0.01
83-
assert exc_info.value.elapsed >= 0.01
82+
error: TaskTimeoutError = exc_info.value # type: ignore[assignment]
83+
assert error.timeout == 0.01
84+
assert error.elapsed >= 0.01
8485

8586
def test_check_timeout_includes_partial_traces(self):
8687
"""TaskTimeoutError should include partial traces if set."""
@@ -93,7 +94,8 @@ def test_check_timeout_includes_partial_traces(self):
9394
with pytest.raises(TaskTimeoutError) as exc_info:
9495
context.check_timeout()
9596

96-
assert exc_info.value.partial_traces == partial_traces
97+
error: TaskTimeoutError = exc_info.value # type: ignore[assignment]
98+
assert error.partial_traces == partial_traces
9799

98100
def test_check_timeout_no_traces_if_not_set(self):
99101
"""TaskTimeoutError should have empty traces if not set."""
@@ -104,7 +106,8 @@ def test_check_timeout_no_traces_if_not_set(self):
104106
with pytest.raises(TaskTimeoutError) as exc_info:
105107
context.check_timeout()
106108

107-
assert exc_info.value.partial_traces == {}
109+
error: TaskTimeoutError = exc_info.value # type: ignore[assignment]
110+
assert error.partial_traces == {}
108111

109112
def test_check_timeout_does_not_raise_before_deadline(self):
110113
"""check_timeout() should not raise before deadline."""

tests/test_core/test_registry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import threading
99
import time
1010
from concurrent.futures import ThreadPoolExecutor
11-
from typing import Any, Dict
11+
from typing import Any, Dict, Optional
1212

1313
from maseval.core.registry import ComponentRegistry
1414
from maseval.core.tracing import TraceableMixin
@@ -21,7 +21,7 @@
2121
class MockTraceableComponent(TraceableMixin):
2222
"""Component that implements TraceableMixin for testing."""
2323

24-
def __init__(self, name: str, trace_data: Dict[str, Any] = None):
24+
def __init__(self, name: str, trace_data: Optional[Dict[str, Any]] = None):
2525
super().__init__()
2626
self._name = name
2727
self._trace_data = trace_data or {"component": name}
@@ -36,7 +36,7 @@ def gather_traces(self) -> Dict[str, Any]:
3636
class MockConfigurableComponent(TraceableMixin, ConfigurableMixin):
3737
"""Component that implements both TraceableMixin and ConfigurableMixin."""
3838

39-
def __init__(self, name: str, config: Dict[str, Any] = None):
39+
def __init__(self, name: str, config: Optional[Dict[str, Any]] = None):
4040
TraceableMixin.__init__(self)
4141
ConfigurableMixin.__init__(self)
4242
self._name = name

0 commit comments

Comments
 (0)