Skip to content

refactor(mypy): un-ignore 7 medium-tier modules#287

Open
lyskov-ai wants to merge 2 commits into
RosettaCommons:productionfrom
lyskov-ai:0005-ratchet-mypy-medium-tier
Open

refactor(mypy): un-ignore 7 medium-tier modules#287
lyskov-ai wants to merge 2 commits into
RosettaCommons:productionfrom
lyskov-ai:0005-ratchet-mypy-medium-tier

Conversation

@lyskov-ai
Copy link
Copy Markdown
Contributor

Type-checking: resolve the type errors in 7 modules and remove them from the [[tool.mypy.overrides]] ignore_errors list (13 → 6 remaining), so mypy now type-checks them.

Most fixes are local narrowing / annotation work. Two are deliberate type-honesty changes, each touching only an unused or impossible path:

  • SchedulerConfig.scheduler is now a required field (was = None, but documented required and dereferenced unconditionally in state_dict/load_state_dict; every construction site passes scheduler=...). A bare SchedulerConfig() now raises instead of building a broken-on-first-use object.
  • XPUAccelerator.name @property@staticmethod, to match lightning's Accelerator ABC (@staticmethod @abstractmethod def name() -> str). No foundry code reads .name; lightning calls it per its own contract.

Per-module details are in the commit message.

lyskov-ai and others added 2 commits June 3, 2026 03:24
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>
@lyskov-ai lyskov-ai force-pushed the 0005-ratchet-mypy-medium-tier branch from b50ff55 to 842d183 Compare June 3, 2026 03:25
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