Skip to content

Comments

Fix ty logger protocol typing in sandbox retry setup#835

Merged
willccbb merged 5 commits intomainfrom
codex/fix-type-hints-in-ci
Feb 6, 2026
Merged

Fix ty logger protocol typing in sandbox retry setup#835
willccbb merged 5 commits intomainfrom
codex/fix-type-hints-in-ci

Conversation

@willccbb
Copy link
Member

@willccbb willccbb commented Feb 6, 2026

Motivation

  • Silence ty errors where tenacity.before_sleep_log expects a LoggerProtocol by providing the correct structural type instead of broad ignores, without changing runtime behavior.

Description

  • Import LoggerProtocol from tenacity._utils and cast the logger arguments passed to tc.before_sleep_log in verifiers/envs/sandbox_env.py and verifiers/utils/sandbox_exec_utils.py, leaving functionality unchanged.

Testing

  • Ran uv run ty check verifiers and uv run ruff check verifiers/envs/sandbox_env.py verifiers/utils/sandbox_exec_utils.py, which completed with no ty errors for the modified targets (repository-wide warnings remain unrelated to these changes).

Codex Task


Note

Low Risk
Mostly type-annotation and linting changes with small defensive checks; risk is limited to subtle behavior shifts in logging/metrics wiring and RL weight-sync edge cases.

Overview
This PR primarily addresses static typing friction (especially ty) by removing broad type: ignore annotations, adding targeted cast()s/Protocols, and adjusting a few call sites to satisfy stricter type expectations.

Key tweaks include introducing a local LoggerProtocol and casting loggers passed into Tenacity’s before_sleep_log in sandbox retry helpers, hardening a few potentially-dynamic attributes (e.g., PEFT warnings_issued, vLLM weight sync client_rank, rubric function naming), and small API/typing adjustments such as renaming RLTrainer.log_metrics parameters and improving message/dataset typings. It also trims browser env lazy exports and updates ty config to ignore redundant-cast.

Written by Cursor Bugbot for commit 2c6bee9. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


parsed_answer = await self.run_in_executor(
lambda: parse(f"\\boxed{{{answer}}}", parsing_timeout=None) # type: ignore
lambda: parse(f"\\boxed{{{answer}}}", parsing_timeout=cast(int, None))
Copy link

Choose a reason for hiding this comment

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

Misleading cast of None to int hides type mismatch

Low Severity

cast(int, None) actively lies to the type checker by asserting None is an int, which is worse than the original # type: ignore it replaces. The old annotation honestly said "skip this check," while the new one claims there's no issue at all. This hides the fact that None is being passed where parsing_timeout expects int, making it harder for future developers to understand the actual runtime value and masking the type incompatibility from refactoring tools. A cast(Any, None) or keeping the original # type: ignore would be more honest.

Additional Locations (1)

Fix in Cursor Fix in Web

@willccbb willccbb merged commit 7f8d891 into main Feb 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant