Skip to content

EvalScorer type rejects scorers returning list[Score] #443

@barrettpyke

Description

Description

The SDK’s OneOrMoreScores type currently includes list[ScoreLike] as the multi-score return type. Because Python lists are invariant / mutable, static type checkers reject scorers that return list[Score].

Reproduction

Run pyright on the following code:

from braintrust import Score
from braintrust.framework import EvalScorer

def scorer(input: str, output: str, expected: str | None = None) -> list[Score]:
    return [Score(name="match", score=1.0)]

typed_scorer: EvalScorer[str, str, str] = scorer

Expected
It should allow you to return a list[Score].

Observed
You get a type error on line 7:
Function return type "list[Score]" is incompatible with type "OneOrMoreScores"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions