← Back to Pull requests

Run mypy once per group of folders (quality kit 1.1.0) #13

Closed
unknown closed this pull request without merging on Nov 23, 2026 06:23 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 06:08 UTC
Author

What this changes

Quality kit 1.1.0, a minor release: mypy groups, the gap that keeps kleidos-dev/videos red. Its scripts sit in plain folders that repeat file names (score.py eleven times, check_measure.py, ...), so one mypy run over the tree stops at "Duplicate module named" and checks nothing.

  • A repository may declare [[tool.kleidos-quality.mypy-groups]] in its pyproject.toml: a name and the files (folders, files, or globs such as music/*.py for a folder without its subfolders) of one mypy run. A group sets nothing else, so every run reads the same [tool.mypy], the kit's strict block included; with groups, [tool.mypy] sets no files.

  • quality/mypy_groups.py, a new copy of the python profile (.github/quality/mypy_groups.py, listed in kit.toml and KIT_COPIES), runs one mypy per group, each in a cache directory of its own, every group even after one fails, passing mypy the group's paths and nothing else. Without groups it runs a bare mypy, as before. Standard library only.

  • The mypy hook of the pre-commit-python block runs it (python3 .github/quality/mypy_groups.py); --group NAME runs one group locally.

  • reusable-mypy.yml runs the kit's copy with --github: a fold per group in the log, an error annotation per failing group, and a table of every group (clean or not, with mypy's own summary line) in the job summary; the job fails after all groups ran.

  • check_quality.py holds every tracked Python file to exactly one group (or to files, without groups), refuses a group key other than name and files, a bad name or path, files beside groups and any other [tool.kleidos-quality] key, with no waiver; reports a group folder or glob that holds no Python file; and reports two files of one mypy run that mypy would name the same module (packages above the file, then its stem), with or without groups.

  • docs/quality.md (a "mypy groups" section under the Python rules, the profile table, the workflow table, adoption step 8, Overrides 6), quality/README.md, quality/CHANGELOG.md, quality/VERSION 1.1.0.
  • Why minor: a repository without groups runs exactly what it ran before, and the duplicate-module check only reports what that run already fails on.

    How it was tested

    No hardware.

  • python -m unittest discover -s quality/tests: 134 tests, 24 new in quality/tests/test_mypy_groups.py (declarations, the runner against a stand-in mypy on the PATH, the GitHub output, conformance: one group per file, stale folders, globs, duplicates, a missing runner copy, the hook and workflow wiring).

  • ruff check, ruff format, mypy (strict, 18 files) and pre-commit run --all-files on this repository: clean. sync.py --write . records the new copy; sync.py --release-check: 1.1.0 to tag at the merge commit.

  • sync.py --preview on boards, brand, social, cla, qa, agents and posts: 0 problems each. videos: 21 (the duplicate modules mypy already stops at). On a videos clone with 18 groups declared, check_quality.py is clean and mypy_groups.py --github runs all 18 with real mypy (1 clean, 17 with the type errors the videos sync fixes next), no duplicate-module stop.
  • Checklist

  • The documentation is updated in the same change, or none was needed.

  • Everything is in English, and commit messages are in the imperative mood.

  • I contribute this under the license of this repository (CONTRIBUTING.md).
  • Diff: 439 lines (+329 / -110) across 5 files Reviewer: jmrplens Review duration: 15m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 439 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #13"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%