Skip to content

MAINT Fix canonical typing - #3064

Open
Roman Lutz (romanlutz) wants to merge 1 commit into
microsoft:mainfrom
romanlutz:romanlutz-wider-typing-failures
Open

Roman Lutz (romanlutz) wants to merge 1 commit into
microsoft:mainfrom
romanlutz:romanlutz-wider-typing-failures

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

The existing production-plus-unit typing check fails even when production typing passes. Unresolved test-helper imports account for much of the noise, but fixture annotations, mock return types, signature-erasing decorators, and several real test defects also need correction.

This restores the complete pyrit tests\unit check without weakening checker rules:

  • Align pytest and ty helper roots and normalize imports to unit.* and end_to_end.*. Keep make ty on its existing production-plus-unit scope with locked dependencies and all extras.
  • Correct generator fixtures, honest mock return types, optional values, and test input/output narrowing. Use canonical constructor fields in ordinary setup while retaining dedicated legacy-alias and invalid-input tests.
  • Preserve argument and return types through the rate limiter and custom-result retry decorator. Their runtime pacing and retry behavior are unchanged.
  • Make the embedding mock assertion actually execute, preserve cancellation and partial-setup cleanup, and add signature/result regression coverage.

Production model/scorer APIs, CI hook scope, checker severities, and directory-level overrides are unchanged. Two line-specific ty exemptions retain deliberately invalid positional construction and an intentionally unresolved annotation. Integration, partner-integration, and top-level build-script typing remediation remains separate and was not rerun.

No breaking runtime API change is intended.

Tests and Documentation

Validated in this worktree with Python 3.13.13, uv 0.11.8, ty 0.0.84, and all extras:

Command Result
uv run --frozen --no-sync ty check pyrit --output-format concise Passed, zero diagnostics
uv run --frozen --no-sync ty check pyrit tests\unit --output-format concise Passed, zero diagnostics; also rechecked after committing
uv run --frozen --no-sync ruff check $changed Passed for all changed Python files
uv run --frozen --no-sync ruff format --check $changed Passed for all changed Python files
uv run --frozen --no-sync -m pytest -n 4 --dist=loadfile -q --disable-warnings $files 3,193 passed, 13 warnings; $files contains all changed test modules
uv run --frozen --no-sync -m pytest -n 4 --dist=loadfile tests\unit -q --disable-warnings 24,855 passed, 1 failed, 21 skipped, 81 subtests passed, 397 warnings
Commit hooks, including uv run --frozen --extra all --link-mode=copy ty check pyrit Passed with UV_PYTHON set to the owned Python 3.13 interpreter; no hooks bypassed

The runtime runs used Hugging Face/Transformers/datasets offline settings. make is unavailable on this Windows host, so the full-suite command runs the Makefile's four-worker unit-test recipe while retaining the owned all-extras environment.

Full-suite caveat: The unchanged tests\unit\setup\test_reinitialization.py::test_replacement_precedence_interpolation_empty_and_omission mocks setting CentralMemory without installing a memory fixture. It passes in isolation without target configuration, but fails when endpoint, key, and model environment variables cause the real target initializer to construct a target. Process-local dummy configuration reproduces the same failure under both the current helper roots and the original pythonpath=.. The test, unit fixture file, and traceback source files are unchanged from the starting HEAD. This is not a green full-suite result or a clean-HEAD full-suite comparison; the unrelated fixture issue is left unchanged.

Updated the local development guide to distinguish production, canonical, and expanded typing commands and explain interpreter versus checker target versions. Added tests for typed decorator forwarding/results and optional-task cleanup; retained legacy constructor-alias, negative-input, and cancellation coverage.

JupyText was not run; no notebook or executable documentation example was changed.

Align test-helper import roots, correct fixture and mock contracts, and preserve decorator signatures without relaxing checker rules. Keep legacy validation and teardown behavior covered.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant