Repository navigation
refactor: fix type errors that pyrefly 1.4 reports in whitelisted files - #5296
Conversation
|
/ok to test 93db711 |
Pyrefly 1.4.0 reports 106 errors in files that are clean under the pinned 0.24.2. This fixes the 15 that need no design decision: local annotations that were narrower than what the code assigns, names bound in one branch and read in another, and one generator typed as a plain iterator. No runtime behaviour changes and no suppressions are added. The files stay clean under 0.24.2. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Robin Nabel <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
LGTM. I reviewed all 11 changed files and their directly affected callers, contracts and existing tests. I found no qualifying issues.
Static review only. I did not run tests, lint or Pyrefly, and CI status was unavailable. The reported test results were not independently verified.
Generated by Codex
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
93db711 to
684dd48
Compare
|
/ok to test 684dd48 |
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for fixing the type errors that Pyrefly 1.4 reports in the whitelisted files, this is careful and tidy work! It gets these files ready for the Pyrefly upgrade.
Great to see the Pyrefly 1.4.0 before/after error counts, the 0.24.2 result and the unit-suite pass/skip counts posted in the description: the effect of the change is clear to see.
Scope: the PR diff, plus the callers and consumers of each changed annotation, at 684dd48
Checked:
- Runtime behaviour — unchanged: with annotations stripped, the base and head ASTs differ only in the visible restructurings (
idle/activecomputed inside the branch that prints them inprint_performance_metrics,source_identityas an optional inNemoGymDataset, the two-way unpack in_gather_tp_gate_up_weight,int(...)around.item()), and each gives the same result on every path. - New annotations — each is true for its assignments and consumers:
mappinginvllm_backend.pymatches themerged_slice: tuple[slice, ...] | Noneits consumers declare,placementsonly ever holdsShard/Replicate, and_object_payloadsis a generator whose only caller iscontextlib.closing(...), which needs.close().tq_mooncake_checkpoint.py:945 UnitServer'slockwidened tothreading.Lock | threading.RLock— the right direction: the storage unit passes anRLockbecause its handlers re-take the same lock, the tests pass a plainLock, and the lock is only used aswith self.lock:;from __future__ import annotationsincontrol.pykeeps the union from being evaluated at runtime.control.py:120-124,nixl_storage_unit.py:214- Pyrefly results — on 1.4.0 the 15 targeted errors are gone (14 in the changed files plus the
RLockargument error at theUnitServercall site innixl_storage_unit.py) and no new error appears, with no suppression comments or casts added; the pinned 0.24.2 passes in theLint checkjob at this head.
LGTM — no remaining findings.
Generated by Claude Code
What does this PR do ?
Fixes 15 type errors that Pyrefly 1.4.0 reports in files that are clean under the pinned 0.24.2, so the Pyrefly upgrade in #5298 starts from a smaller baseline. No runtime behaviour changes.
Issues
None. This is the first of two PRs; the upgrade itself is #5298, stacked on this branch.
Usage
Not applicable: annotations and small restructurings only.
Before your PR is "Ready for review"
Pre checks:
Additional Information
What changed (11 files, +25 −20)
placementsinnccl_reshard_utils.py,mappinginvllm_backend.py,target_missinginnvfp4_pertoken.py,original_valuesin a diagnostics tool.idle/activeinprint_performance_metrics,source_identityinNemoGymDataset, and a function-local import insingle_controller_utils/setup.pythat moves to the existing module-level import of the same module._object_payloadsis a generator passed tocontextlib.closing, so it is annotatedGeneratorinstead ofIterator.UnitServer.__init__acceptsthreading.Lock | threading.RLock; the storage unit already passes anRLock._gather_tp_gate_up_weight, andint(...)around a.item()used as an index.No suppression comments or casts are added.
What is left
Pyrefly 1.4.0 goes from 106 errors in 45 files to 91 in 37. The rest need a design decision (override signatures,
NestedKeyfield types,TypedDictshapes, values typedobject) and are recorded in the baseline by the upgrade PR.Latent issues noticed, not changed here
TimeoutChecker.mark_iterationraisesUnboundLocalErrorif called beforestart_iterations(). Every in-repo caller starts first.do_post/_post_localinsglang/utils/http_utils.pyraiseUnboundLocalErrorwithmax_retries <= 0.HttpClient.postvalidates the value as positive, so it is only reachable by calling the actor method directly.Testing
Run in a Linux container with the locked environment (
uv sync --frozen), CPU only:main.🤖 Generated with Claude Code