refactor(mypy): un-ignore utils/{ddp,rigid,datasets}#294
Merged
woodsh17 merged 5 commits intoJun 3, 2026
Conversation
Fix each module's single pre-existing type error with a pure annotation or setattr change (no behavior change) and remove it from the [[tool.mypy.overrides]] ignore_errors list: - callbacks/train_logging: loss_trackers: dict[str, MeanMetric] - callbacks/metrics_logging: seen_examples: set[str] - common: setattr(wrapper, "_has_run", True) for the @wraps wrapper - hydra/resolvers: attribute_path: str | None (body already guards) - inference_engines/base: base_overrides: dict[str, Any] 13 modules remain on the ignore list. mypy now type-checks the 5 newly-included modules cleanly. Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Resolve the type errors in and remove from the [[tool.mypy.overrides]] ignore_errors list. Mostly narrowing / annotation fixes; two deliberate type-honesty fixes flagged below. - utils/weights: lowercase `any` -> `Any` in _PatternPolicyMixin (4x); assert-narrow fallback_policy at the call site (matches get_policy idiom) - model/layers/blocks: class-level w/b: torch.Tensor for the registered buffers (avoids nn.Module's Tensor | Module __getattr__ fallback) - utils/components: is-None narrowing + tip_names local in get_name_mask's TIP branch (exists() can't narrow for mypy); drop orphaned exists import - utils/logging: str(field) for the tree key; assign to a new hparams local rather than reassigning the typed cfg param - foundry_cli/download_checkpoints: guard on `hasher is not None`; total_size = 0.0 for the float accumulation - training/schedulers: SchedulerConfig.scheduler is now a required field (was = None, but documented required and assumed non-None everywhere) - utils/xpu/xpu_accelerator: name @Property -> @staticmethod to match lightning's Accelerator ABC 6 hard-tier modules remain on the ignore list. Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Fix the 11 type errors in foundry.metrics.metric and remove it from the [tool.mypy.overrides] ignore_errors list (5 hard-tier modules remain). - str(name) coercion of DictConfig.items() keys (str|bytes|int|... union) - exists() -> 'is not None' narrowing; drop orphaned atomworks import - widen compute_from_kwargs -> dict|list and kwargs_to_compute_args -> dict|None to match the actual returns / documented contract (callers already handle them) - three type: ignore[arg-type] on nested_dict.get/getitem for an upstream atomworks annotation bug (param typed dict[tuple,...] but navigated as nested dict[str,Any]); warn_unused_ignores will flag them if upstream is fixed No behavior change. All gates green (ruff, mypy 41 files, pytest 27 passed). Co-authored-by: Sergey Lyskov <sergey.lyskov@jhu.edu>
Clear the three remaining foundry.utils.* modules off the mypy ignore_errors list (47 errors: ddp 12, rigid 16, datasets 19). Type-honesty and annotation fixes only, no behavior change: narrow DictConfig|dict params to DictConfig where attribute access requires it (item access kept where a plain-dict default is real), honest int|None / Tensor|None widenings, variable renames to avoid type-reuse, str() coercion of DictConfig keys, the file's own if/elif/else narrowing pattern, and documented type: ignore / cast for genuine torch and atomworks stub limitations. Two hard-tier modules remain (callbacks/health_logging, trainers/fabric). Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
woodsh17
approved these changes
Jun 3, 2026
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.
Type-checking: fix the type errors in three
foundry.utilsmodules —ddp,rigid,datasets— and remove them from theignore_errorslist (5 → 2 remaining), so mypy now type-checks them. No behavior change.Fixes are type-honesty / annotation only: honest
… | Nonewidenings,DictConfigvs plain-dictcorrections where attribute access is used, variable renames for type reuse, and a few documented# type: ignore/castfor genuine torch / atomworks stub gaps.Per-module details are in the commit message.