← Back to Pull requests

Fix bad-dunder-name false positives for __prepare__, __mro_entries__, __buffer__, __release_buffer__ and __replace__ #11793

Open
unknown opened this pull request with 181 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 08, 2026 17:45 UTC
Author

Type of Changes

| | Type |
| --- | ---------------------- |
| ✓ | :bug: Bug fix |
| | :sparkles: New feature |
| | :hammer: Refactoring |
| | :scroll: Docs |

Description

bad-dunder-name reported five valid data model methods because they were missing from EXTRA_DUNDER_METHODS in pylint/constants.py (same kind of gap as #8613 and #10435):

  • __prepare__ (PEP 3115) and __mro_entries__ (PEP 560): added to the (0, 0) list, since they exist on every supported Python version.

  • __buffer__ / __release_buffer__ (PEP 688): added under (3, 12).

  • __replace__ (used by copy.replace()): added under (3, 13).
  • Because they are version-gated, the 3.12/3.13 names are still reported when py-version is older, matching how _add_alias_ / _add_value_alias_ are handled.

    I put them in EXTRA_DUNDER_METHODS rather than DUNDER_METHODS so this change does not also start emitting unnecessary-dunder-call for explicit calls to them; that could be a separate follow-up if wanted.

    Tests: two new functional tests in tests/functional/ext/bad_dunder/:

  • bad_dunder_name_py313 (py-version=3.13): all five methods are accepted.

  • bad_dunder_name_py311 (py-version=3.11): __prepare__ / __mro_entries__ are accepted, while __buffer__, __release_buffer__ and __replace__ are still reported.
  • Both fail without the change and pass with it.

    Closes #11791

    Diff: 181 lines (+135 / -46) across 2 files Reviewer: chrikrah Review duration: 7608m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 181 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.311
    Real PR Conversation Timeline
    1 comments
    "Review active on #11793"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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.6% (MEDIUM) · Higher = larger blast radius
    35.6%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 19.0% · Safe to merge
    19.0%