← Back to Pull requests

Types refactor and inheritance #1264

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

proposed refactor of types to make inheritance easier, and basic inheritance

<!-- This is an auto-generated description by cubic. -->
---

Summary by cubic


Reworks how types are modeled and adds class inheritance for user classes.

Native types and exception classes now come from one generated table (native_types! in types/native.rs), replacing BuiltinType and the inline ExcType builtin. py_type() returns a TypeRef that covers both native types and user classes, so isinstance(), except matching, and type() share a single implementation. Numeric binary operators skip the class lookup when both operands are immediate, and builtin type names resolve by binary search over an inline sorted table.

New Features

  • Classes accept bases with C3 MRO, issubclass(), and object.__new__/__init__/__init_subclass__, matching CPython's error and copy semantics. Class keywords reach __init_subclass__, obj.__class__ can be reassigned, and reflected operators and == prefer the subclass. Zero-argument super() is deferred until descriptors land; base methods are called explicitly.

  • Native type class attributes and class methods (like date.min and Path.cwd()) now go through the table.

  • Native types and exceptions can't be used as bases yet; they raise TypeError.
  • Migration

  • Old dumps still load: legacy type shapes are read back, and type names and postcard indices stay pinned. A pinned fixture stores pre-refactor types as dump and hash keys so it can't be regenerated.
  • <sup>Written for commit 6d43ef4003485be38ef75f9c0e5c5c824a213e20. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1264?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/pydantic/monty/1264?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1264&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 341 lines (+255 / -86) across 4 files Reviewer: samuelcolvin Review duration: 14003m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 341 lines diff across 4 files
    0.47
    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.349
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1264"
    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: 47.3% (MEDIUM) · Higher = larger blast radius
    47.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: 18.7% · Safe to merge
    18.7%
    Repository