← Back to Pull requests

[python] Add type hints to the tree updater tests #12913

Closed
unknown closed this pull request without merging on Dec 01, 2026 13:54 UTC
View on GitHub
unknown unknown commented on Dec 01, 2026 07:13 UTC
Author

This PR addresses part of issue #6496.

Part of #6496, following the same pattern as #12838, #12901 and #12905.

This PR adds tests/python/test_updaters.py to the list of files checked by mypy in CI
(ops/script/type_check_python.py).

Changes needed for the file to pass mypy (disallow_untyped_defs is enabled):

  • Annotate the remaining tests: test_exact (param: Dict[str, Any], num_rounds: int, dataset: tm.TestDataset),

  • test_pruner, test_hist_categorical, test_hist_degenerate_case and test_sparse.
  • Type the two evaluation logs in test_hist_categorical as TrainingCallback.EvalsLog.
  • The test logic, expected values and assertions are unchanged.

    Most of the other untyped files in tests/python/ (test_basic.py, test_basic_models.py, test_callback.py,
    test_dmatrix.py, test_parse_tree.py, test_predict.py, test_ranking.py, test_survival.py,
    test_with_arrow.py, test_with_pandas.py, test_with_sklearn.py) are touched by open PRs at the moment, so I left
    them out to avoid conflicts with those PRs.

    Verified locally (Python 3.12, mypy 2.4.1, ruff 0.16.6):

    cd python-package && mypy ../tests/python/test_updaters.py ../ops/script/type_check_python.py
    # Success on this branch; master reports 5 errors for test_updaters.py

    pytest tests/python/test_updaters.py
    # 33 passed (same count as master), against a libxgboost built from master

    ruff check and ruff format --check (pre-commit config) pass on the changed files.

    Diff: 192 lines (+144 / -48) across 2 files Reviewer: trivialfis Review duration: 401m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 192 lines diff across 2 files
    0.36
    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.315
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #12913"
    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: 35.9% (MEDIUM) · Higher = larger blast radius
    35.9%
    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: 14.2% · Safe to merge
    14.2%
    Repository