Skip to content

Fix pyright type errors#138

Closed
benjibc wants to merge 1 commit intomainfrom
cursor/fix-pyright-type-errors-0bcb
Closed

Fix pyright type errors#138
benjibc wants to merge 1 commit intomainfrom
cursor/fix-pyright-type-errors-0bcb

Conversation

@benjibc
Copy link
Copy Markdown
Contributor

@benjibc benjibc commented Aug 30, 2025


name: Pull Request
about: Propose changes to the codebase
title: "Fix: Resolve Pyright type errors in reward modules"
labels: ''
assignees: ''


Description

This PR addresses a batch of Pyright type errors, primarily related to the Message.content field, which can be either a str or a list of content parts.

A new utility module, eval_protocol/rewards/_content_utils.py, has been introduced with to_text and to_text_any helpers. These functions normalize Message.content into a plain string, preventing type checker errors when string operations are performed.

These helpers have been integrated across various reward modules, including accuracy.py, apps_coding_reward.py, json_schema.py, language_consistency.py, length.py, list_comparison_math_reward.py, math.py, multiple_choice_math_reward.py, reasoning_steps.py, and tag_count.py.

Additionally, specific type issues such as unbound variables in apps_coding_reward.py, list type invariance in math.py, and import/call signature issues in json_schema.py have been resolved.

This change resolves approximately 30+ type errors, improving the codebase's type safety and maintainability.

Fixes # (issue)
Implements # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality) - New utility module
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Refactoring/Code cleanup
  • Build/CI/CD related changes
  • Other (please describe):

How Has This Been Tested?

The changes were verified by running the basedpyright type checker locally before and after the modifications.
Spot checks confirmed zero errors in accuracy.py, language_consistency.py, tag_count.py, reasoning_steps.py, multiple_choice_math_reward.py, apps_coding_reward.py, length.py, and math.py.

Test Configuration:

  • Toolchain: basedpyright (via pre-commit hook)

Checklist:

  • My code follows the style guidelines of this project (ran black ., isort ., flake8 .)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Screenshots (if applicable)

Additional context

This PR addresses the first batch of Pyright errors as requested. Remaining errors, largely related to missing optional dependencies and other modules, can be tackled in subsequent PRs.


Open in Cursor Open in Web

@cursor
Copy link
Copy Markdown

cursor bot commented Aug 30, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@benjibc benjibc closed this Aug 30, 2025
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.

2 participants