Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

📝 Changes Description

The GEPAFeedbackMetric and PredictorFeedbackFn Protocol classes were missing the self parameter in their __call__ methods, causing type checker errors when users implement conforming metric functions:

error: Argument of type "(gold: ..., pred: ..., ...) -> float" cannot be assigned to parameter "metric" of type "GEPAFeedbackMetric"
    "FunctionType" is incompatible with protocol "GEPAFeedbackMetric"
      Could not bind method "__call__" because "FunctionType" is not assignable to parameter "gold"

Changes:

  • Added self as first parameter to GEPAFeedbackMetric.__call__ in dspy/teleprompt/gepa/gepa.py
  • Added self as first parameter to PredictorFeedbackFn.__call__ in dspy/teleprompt/gepa/gepa_utils.py

✅ Contributor Checklist

  • Pre-Commit checks are passing (locally and remotely)
  • Title of your PR / MR corresponds to the required format
  • Commit message follows required format {label}(dspy): {message}

⚠️ Warnings

None.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] GEPAFeedbackMetric Protocol missing 'self' parameter causes type checker errors</issue_title>
<issue_description>### 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</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ackFn Protocol __call__ methods

Co-authored-by: TomeHirata <[email protected]>
Copilot AI changed the title [WIP] Fix missing 'self' parameter in GEPAFeedbackMetric protocol Fix GEPAFeedbackMetric Protocol missing 'self' parameter Dec 4, 2025
Copilot AI requested a review from TomeHirata December 4, 2025 07:55
Copilot finished work on behalf of TomeHirata December 4, 2025 07:55
Copy link
Collaborator

@TomeHirata TomeHirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomeHirata TomeHirata marked this pull request as ready for review December 4, 2025 07:59
@TomeHirata TomeHirata merged commit ed01c88 into main Dec 4, 2025
24 checks passed
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.

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

2 participants