← Back to Pull requests

test(profiling): fix the typing debt in test_product #22229

Closed
unknown closed this pull request without merging on Dec 01, 2026 17:38 UTC
View on GitHub
unknown unknown commented on Dec 01, 2026 15:39 UTC
Author

Description

Fixes the seven mypy errors in tests/profiling/test_product.py that exist on main tip, so the file can be staged and type-checked cleanly. They surface only through the pre-commit mypy hook (CI typing covers ddtrace/, ddtrace_commands and docs per mypy.ini files=), which is how #22195 hit them; that PR lists the module as a temporary ignore_errors exclusion, which this PR makes unnecessary.

  • Three Statement is unreachable: each test asserts the same expression with is True and later is False (or the reverse); mypy narrows the member expression and the narrowing survives the callback(...) calls in between, so the second assert is statically false and the rest of the function is dead code to mypy. The fix reads the value through a fresh local for the second assert (through the first where the narrowed value would otherwise flow into the binding).

  • Two attr-defined: ddtrace.internal.profiling.product renames its profiling_config import, so accessing it through that module is an implicit re-export. Monkeypatch the module-level import from its origin instead — the same object.

  • Two unused type: ignore[attr-defined] comments on _profiler.status, stale since the attribute became typed.
  • Customer impact

    None: test-only change.

    Testing

  • scripts/lint typing -- tests/profiling/test_product.py: clean (was 7 errors).

  • profiling::profile suite, py3.9 (a9a4c7c1bb09): 133 passed — the full file.

  • py3.11 (985b26efc887): 603 passed, 128 skipped, 6 xfailed across tests/profiling, including the full file.
  • Risks

    None: the locals bind the same values the asserts read, and the monkeypatch target is the same settings object.

    Release Notes

    No release note: test-only change (test type needs neither a note nor changelog/no-changelog per docs/releasenotes.rst).

    Diff: 231 lines (+173 / -58) across 2 files Reviewer: gyuheon0h Review duration: 118m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 231 lines diff across 2 files
    0.37
    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.326
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #22229"
    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: 37% (MEDIUM) · Higher = larger blast radius
    37%
    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.6% · Safe to merge
    14.6%