Skip to content

Add enforced mypy --strict type gate on src/bsff (97→0)#114

Open
neuron7xLab wants to merge 3 commits into
mainfrom
harden/mypy-strict-src
Open

Add enforced mypy --strict type gate on src/bsff (97→0)#114
neuron7xLab wants to merge 3 commits into
mainfrom
harden/mypy-strict-src

Conversation

@neuron7xLab

Copy link
Copy Markdown
Owner

The repository had no mypy gate (no config, not wired into CI), so 97 --strict type errors across 21 files were never caught. This adds an enforced gate and brings src/bsff to zero.

What

  • pyproject.toml: [tool.mypy] strict=true, files=src/bsff; ignore_missing_imports per-module for stubless third-party libs (moabb/scipy/sklearn/statsmodels/pingouin/pandas_flavor/mne).
  • .github/workflows/ci.yml: python -m mypy added to the lint job — enforced on every PR, not a one-off.
  • 19 src files: real annotations only. Typed untyped funcs, filled bare generics, fixed no-any-return with concrete types, narrowed object→concrete via TypedDicts + one boundary cast per call site (repo idiom), NDArray[np.float64] for numpy, Literal narrowing.

Discipline

  • Zero new # type: ignore, no Any-widening where a concrete type fits.
  • Annotations/typing only — no runtime-behavior change.
  • mypy --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

…> 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>
Comment thread src/bsff/pipeline.py
from .evidence import EvidenceGraph, StageResult, stable_sha256
from .policy import PolicyProfile, adapt_policy_for_signal
from .registry import StageRegistry
from .registry import PipelineStage, StageRegistry

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .github/workflows/ci.yml
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]'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

neuron7xLab and others added 2 commits July 1, 2026 13:51
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>
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.

2 participants