Skip to content

fix(framework): split Output TypeVar into Output and Expected#243

Merged
Abhijeet Prasad (AbhiPrasad) merged 3 commits intomainfrom
fix/eval-expected-typevar
Apr 10, 2026
Merged

fix(framework): split Output TypeVar into Output and Expected#243
Abhijeet Prasad (AbhiPrasad) merged 3 commits intomainfrom
fix/eval-expected-typevar

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

resolves #240

The Eval generic Output parameter was shared across three positions: task return type, EvalCase.expected, and scorer args. When the expected data type differs from the task output (e.g. assertion specs vs model output), type checkers reject the call because Output can't unify.

Introduce a separate Expected TypeVar so data binds Expected and task binds Output independently. Add a test_types nox session that runs pyright, mypy, and pytest on py/src/braintrust/type_tests/.

Nova (SFK) and others added 2 commits April 9, 2026 22:48
…240)

The `Eval` generic `Output` parameter was shared across three positions:
task return type, `EvalCase.expected`, and scorer args. When the expected
data type differs from the task output (e.g. assertion specs vs model
output), type checkers reject the call because `Output` can't unify.

Introduce a separate `Expected` TypeVar so `data` binds `Expected` and
`task` binds `Output` independently. Add a `test_types` nox session that
runs pyright, mypy, and pytest on `py/src/braintrust/type_tests/`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pin to pyright==1.1.408 and mypy==1.20.0 to avoid flaky CI from
upstream type checker releases introducing stricter checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Evaluator is now Generic[Input, Output, Expected] after the TypeVar
split. Python 3.10 enforces generic param counts at runtime, so the
2-param Evaluator[Any, Any] in server.py caused a TypeError on import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit f2412f0 into main Apr 10, 2026
59 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the fix/eval-expected-typevar branch April 10, 2026 01:09
Abhijeet Prasad (AbhiPrasad) added a commit that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval generic Output parameter can't unify when expected and task return type differ

2 participants