-
Notifications
You must be signed in to change notification settings - Fork 7
Complete Pyright Migration and Remove Mypy Configuration #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete Pyright Migration and Remove Mypy Configuration #24
Conversation
Co-authored-by: speediedan <[email protected]>
…ce_transition Co-authored-by: speediedan <[email protected]>
Co-authored-by: speediedan <[email protected]>
Co-authored-by: speediedan <[email protected]>
Co-authored-by: speediedan <[email protected]>
Co-authored-by: speediedan <[email protected]>
daae2dc
into
mypy_pyright_conversion_sec_enhance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR successfully completes the migration from mypy to pyright for type checking by removing all mypy configuration and enabling comprehensive type checking in pyright's standard mode. The changes include necessary code fixes to pass the stricter type checking requirements.
Key Changes:
- Removed all mypy configuration from
pyproject.tomland enabled comprehensive type checking in pyright (reportGeneralTypeIssues, reportAssignmentType, reportCallIssue, reportIndexIssue all set to "error") - Fixed variable shadowing in
_reduce_transitionwhere thedecisionparameter was being reused as a tensor variable - Corrected spelling errors: "Recieved" → "Received" in 4 error messages
- Added targeted type ignore comments with specific error codes for runtime-validated patterns
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pyproject.toml | Removed complete [tool.mypy] section (28 lines) and updated pyright configuration to enable comprehensive type checking by setting reportGeneralTypeIssues, reportAssignmentType, reportCallIssue, and reportIndexIssue to "error"; updated comments to remove mypy-parity references |
| src/finetuning_scheduler/fts.py | Fixed variable shadowing in _reduce_transition method by introducing separate variable names (decision_tensor, reduced_decision) instead of reusing the decision parameter |
| src/finetuning_scheduler/fts_supporters.py | Corrected spelling of "Received" in 4 error messages; changed LR scheduler instantiation from keyword to positional argument (consistent with PyTorch API); added type ignore comments for dynamic class validation and ZeroRedundancyOptimizer partition indexing |
| decision = bool(strategy.reduce(decision, reduce_op=ReduceOp.SUM)) # type:ignore[arg-type] | ||
| return decision | ||
| decision_tensor = torch.tensor(int(decision), device=strategy.root_device) | ||
| reduced_decision = bool(strategy.reduce(decision_tensor, reduce_op=ReduceOp.SUM)) # type:ignore[arg-type] |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style inconsistency: Use # type: ignore[arg-type] (with space) instead of # type:ignore[arg-type] (without space) to match the project's existing convention used in most other type ignore comments.
| reduced_decision = bool(strategy.reduce(decision_tensor, reduce_op=ReduceOp.SUM)) # type:ignore[arg-type] | |
| reduced_decision = bool(strategy.reduce(decision_tensor, reduce_op=ReduceOp.SUM)) # type: ignore[arg-type] |
… CI Req Generation Security (#23) * refactor: move torch-only lockfile pruning to Python helper - Add `requirements/utils/prune_torch_deps.py`: - Implements iterative, transitive pruning of packages that are only required by `torch` (e.g., `networkx`, `sympy`, `mpmath`). - Provides a CLI: `python prune_torch_deps.py <lockfile_path>`. - Parses uv lockfile `# via` comments and prunes exclusive transitive deps using safe iterations. - Simplify `requirements/utils/lock_ci_requirements.sh`: - Remove complex awk-based pruning logic and replace it with a simple call: `python "${SCRIPT_DIR}/prune_torch_deps.py" "${lockfile}"`. - Keep nightly lockfile generation behavior and the two-step manual install workflow. - Use `--index` (replaces deprecated `--extra-index-url`) for PyTorch nightly resolution. - Security & maintenance: - Document security rationale: restrict the dependency confusion attack surface by pruning torch-only packages while using `--index-strategy unsafe-best-match` during lockfile generation only. - Keep installation workflow secure: manual two-step install or explicit nightly index for runtime. - Tests & checks: - All unit tests pass (164 passed, 52 skipped). - Pre-commit hooks pass. - Module placed in `requirements/utils/` — not included in `src/` coverage. Files changed: - Added: `requirements/utils/prune_torch_deps.py` - Updated: `requirements/utils/lock_ci_requirements.sh` - Updated: `requirements/ci/requirements.txt` and `requirements/ci/requirements-oldest.txt` (torch-only deps pruned) Notes: - This refactor improves maintainability and makes pruning logic easier to test and extend. - No change to the user-install workflow; nightly torch is still installed separately as before. * initial copilot setup steps workflow, improved CI locked reqs logic, set pyright mode to standard and remove initial warnings * Complete Pyright Migration and Remove Mypy Configuration (#24) * Initial plan * Remove mypy configuration and update pyright comments Co-authored-by: speediedan <[email protected]> * Enable reportAssignmentType check and fix variable shadowing in _reduce_transition Co-authored-by: speediedan <[email protected]> * Enable reportCallIssue check and fix LR scheduler instantiation Co-authored-by: speediedan <[email protected]> * Enable reportIndexIssue check and fix sharded optimizer indexing Co-authored-by: speediedan <[email protected]> * Enable reportGeneralTypeIssues and reorganize pyright config comments Co-authored-by: speediedan <[email protected]> * Fix spelling: Recieved -> Received in error messages Co-authored-by: speediedan <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: speediedan <[email protected]> * fix docstring typo --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: speediedan <[email protected]>
What does this PR do?
Completes migration from mypy to pyright by removing all mypy configuration and enabling comprehensive type checking in standard mode.
Changes
Configuration (
pyproject.toml)[tool.mypy]section entirelyreportAssignmentType,reportCallIssue,reportIndexIssue,reportGeneralTypeIssuesType Fixes
fts.py:_reduce_transition: Fixed variable shadowing wheredecisionparameter was reused for intermediate Tensorfts_supporters.py:_lr_scheduler_sanity_chk: Changed LR scheduler instantiation from keyword to positional argument with type ignore for dynamic class validationfts_supporters.py:_repartition_sharded_optim: Added type ignore for ZeroRedundancyOptimizer partition indexing (runtime-validated API)Code Quality
Result
Pyright passes with 0 errors, 0 warnings in standard mode with comprehensive type checking enforcement.
Does your PR introduce any breaking changes? If yes, please list them.
None
Before submitting
PR review
Anyone in the community is welcome to review the PR.
In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.