Port type checking from mypy to ty#294
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces the mypy type checker with ty across the project — updating dev dependencies, CI workflow, configuration, ignore files, IDE settings, contributor docs, and a couple of small in-code adjustments needed for ty compatibility.
Changes:
- Swap
mypy→tyinrequirements-dev.txt, CI workflow,pyproject.tomlconfig, and docs/templates. - Replace
event.type == "raw_response_event"checks withisinstance(event, RawResponsesStreamEvent)in both RAG modules sotycan narrowevent.data. - Switch a
# type: ignoreto a# ty: ignoresuppression inevals/generate_ground_truth.py.
Show a summary per file
| File | Description |
|---|---|
| requirements-dev.txt | Replace mypy dependency with ty. |
| pyproject.toml | Drop [tool.mypy] config; add [tool.ty.environment] and [tool.ty.analysis] with allowed unresolved imports. |
| .github/workflows/app-tests.yaml | Remove mypy cache step; run ty check with GitHub output format. |
| .github/PULL_REQUEST_TEMPLATE.md | Update checklist to reference ty check. |
| .github/copilot-instructions.md | Update type-checking commands/notes to use ty. |
| .vscode/settings.json | Stop hiding .mypy_cache from explorer. |
| .gitignore | Remove mypy cache ignore entries. |
| src/backend/fastapi_app/rag_simple.py | Import RawResponsesStreamEvent and use isinstance for stream-event narrowing. |
| src/backend/fastapi_app/rag_advanced.py | Same isinstance-based stream-event narrowing change. |
| evals/generate_ground_truth.py | Replace # type: ignore[list-item] with # ty: ignore[invalid-argument-type]. |
Copilot's findings
- Files reviewed: 9/10 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Port Python type checking from
mypytoty.This updates the development dependency, CI type-check command, repo configuration, and related documentation/checklists. It also includes small type-checker compatibility updates for OpenAI Agents stream event narrowing and an eval-only
tysuppression.Does this introduce a breaking change?
When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.
Type of change
Code quality checklist
See CONTRIBUTING.md for more details.
python -m pytest).python -m pytest --covto verify 100% coverage of added linespython -m ty checkto check for type errorsruffmanually on my code.Validation run:
ruff check ./usr/local/bin/python -m ty check . --python-version 3.12 --extra-search-path /home/vscode/.local/lib/python3.12/site-packages