Add enforced mypy --strict type gate on src/bsff (97→0)#114
Add enforced mypy --strict type gate on src/bsff (97→0)#114neuron7xLab wants to merge 3 commits into
Conversation
…> 0) The repo had NO mypy gate at all (no config, not in CI) — so 97 strict-mode type errors across 21 files had never been caught. This adds the gate and brings src/bsff to zero. - pyproject.toml: [tool.mypy] strict=true, files=src/bsff, with per-module ignore_missing_imports for genuinely stubless third-party libs (moabb, scipy, sklearn, statsmodels, pingouin, pandas_flavor, mne) — a library gap, silenced per-module, not globally. - .github/workflows/ci.yml: `python -m mypy` added to the lint job, so the type gate is enforced on every PR, not a one-off cleanup. - 19 src files: real type annotations only. Untyped functions typed; bare generics filled (dict -> dict[str,X]); no-any-return fixed with concrete return types; object->concrete narrowing done via TypedDicts + a single boundary cast per call site (the repo's own idiom), never per-use casts. Numpy arrays typed NDArray[np.float64]. Literal mismatches narrowed properly. Discipline: ZERO new `# type: ignore`, no Any-widening where a concrete type fits. Annotations/typing only — no runtime-behavior change. Full fast test suite green (0 failures), ruff check + format clean, mypy --strict: 0 issues across 50 files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| from .evidence import EvidenceGraph, StageResult, stable_sha256 | ||
| from .policy import PolicyProfile, adapt_policy_for_signal | ||
| from .registry import StageRegistry | ||
| from .registry import PipelineStage, StageRegistry |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 967186d575
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cache: pip | ||
| - run: python -m pip install --upgrade pip | ||
| - run: python -m pip install -e '.[dev]' | ||
| - run: python -m pip install -e '.[dev,stats,leakage]' |
There was a problem hiding this comment.
Install YAML stubs before running mypy
Because this new type gate runs python -m mypy over all of src/bsff, it also checks the lazy import yaml in src/bsff/case.py; this lint environment installs only dev,stats,leakage, while the YAML dependency is a separate extra and no yaml override/stub package is configured. In a fresh CI environment mypy reports the missing YAML stubs/import before any tests run, so the lint job is blocked unless this step installs the YAML typing dependency or the mypy config explicitly ignores yaml.
Useful? React with 👍 / 👎.
CI lint runner (Python 3.12 + latest numpy) ships stubs using `type X = ...` (PEP 695), which mypy rejects under python_version=3.10. Pinned to 3.12 to match the lint runner; runtime floor stays 3.10 via ruff target-version + the 3.10-3.13 test matrix. Reproduced locally with numpy 2.4.3: mypy 0/50. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…yaml stubs in CI CI (py3.12 + latest numpy) surfaced 3 mypy errors local did not: datasets.py no-any-return (numpy typed the returned array as Any under the CI dep set — fixed with an explicit FloatArray return bind, deterministic across environments), and two Library-stubs-not-installed for jsonschema/yaml (added types-jsonschema + types-PyYAML to the CI mypy install; real stubs, not ignore). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The repository had no mypy gate (no config, not wired into CI), so 97
--stricttype errors across 21 files were never caught. This adds an enforced gate and bringssrc/bsffto zero.What
pyproject.toml:[tool.mypy] strict=true, files=src/bsff;ignore_missing_importsper-module for stubless third-party libs (moabb/scipy/sklearn/statsmodels/pingouin/pandas_flavor/mne)..github/workflows/ci.yml:python -m mypyadded to the lint job — enforced on every PR, not a one-off.srcfiles: real annotations only. Typed untyped funcs, filled bare generics, fixedno-any-returnwith concrete types, narrowedobject→concrete via TypedDicts + one boundary cast per call site (repo idiom),NDArray[np.float64]for numpy, Literal narrowing.Discipline
# type: ignore, noAny-widening where a concrete type fits.--strict: 0 issues / 50 files · full fast suite green (0 failures) · ruff check+format clean.Executed as 5 parallel agents over disjoint file sets + integration pass.
🤖 Generated with Claude Code