Skip to content

[Bug] GEPAFeedbackMetric Protocol missing 'self' parameter causes type checker errors #9079

@seehuhn

Description

@seehuhn

What happened?

I am getting unexpected type checker errors for my GEPA objective functions:

voss@porkpie [~] uv run pyright repro.py
/Users/voss/sources/dspy-bug/repro.py
  /Users/voss/sources/dspy-bug/repro.py:9:12 - error: Argument of type "(gold: Unknown, pred: Unknown, trace: Unknown | None = None, pred_name: Unknown | None = None, pred_trace: Unknown | None = None) -> float" cannot be assigned to parameter "metric" of type "GEPAFeedbackMetric" in function "__init__"
    "FunctionType" is incompatible with protocol "GEPAFeedbackMetric"
      Could not bind method "__call__" because "FunctionType" is not assignable to parameter "gold"
        "FunctionType" is not assignable to "Example" (reportArgumentType)
1 error, 0 warnings, 0 informations

I believe that my function is correct, and the the error reported here is a false positive. Test file is below.

Steps to reproduce

View this test file in vscode, or run the type checker as shown above: repro.py.

Note that the problem does not occur for version 3.0.4. Sadly the reason for this is not that the problem has been fixed, but instead the new @experimental(version="3.0.0") decorator on GEPAFeedbackMetric (file "teleprompt/gepa/gepa.py") confuses the type checker.

DSPy version

3.0.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions