← Back to Pull requests

Implement pure Path properties: drive, root, anchor, is_reserved, and match #1316

Open
unknown opened this pull request with 368 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 13, 2026 01:59 UTC
Author

Description

Implements standard pure pathlib.Path properties and methods (drive, root, anchor, is_reserved(), and match()), closing compatibility gaps identified in #1060 and documented in limitations/pathlib.md.

Context: Downstream commit BucketHeadP65/ai-studio@b0ec4fa documented these missing attributes as active compatibility blockers in sandboxed agent workflows.

Summary of Changes:


  • Path.drive: Returns "" for POSIX paths.

  • Path.root: Returns "/" for absolute paths and "" for relative paths.

  • Path.anchor: Returns "/" for absolute paths and "" for relative paths (drive + root).

  • Path.is_reserved(): Returns False on POSIX systems; validates argument arity (takes 0 arguments).

  • *Path.match(path_pattern, , case_sensitive=None): Matches paths against glob-style wildcard patterns using SegmentPattern with CPython 3.14 component-wise matching semantics and case-sensitivity handling.

  • intern.rs: Registered Anchor, Drive, IsReserved, PathPattern, and Root in StaticStrings.

  • limitations/pathlib.md: Updated documentation of pure methods and visible argument arity count.

  • pathlib__pure.py*: Added test cases verifying parity with CPython across all new attributes, methods, edge cases, and argument errors.
  • <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Implements the pure pathlib.Path properties drive, root, anchor and the is_reserved() and match() methods, closing compatibility gaps identified in #1060 and documented in limitations/pathlib.md.

  • drive is always "" on POSIX; root and anchor return "/" for absolute paths and "" otherwise; is_reserved() always returns False and rejects extra arguments.

  • match() follows CPython 3.14 component-wise matching via SegmentPattern, supports the case_sensitive keyword, and raises ValueError: empty pattern for empty patterns ("", ".").

  • Root matching is strict, so Path('/').match('') returns False, matching CPython; match() also accepts Path objects as patterns and raises TypeError for other types.

  • SegmentPattern polls the ResourceTracker to cap backtracking on pathological patterns and documents the ResourceError it can raise.
  • <sup>Written for commit 2aada52b171b546f2c639a52e4bf662e0798b7dd. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1316?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>

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

    Diff: 368 lines (+276 / -92) across 4 files Reviewer: davidhewitt Review duration: 14069m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 368 lines diff across 4 files
    0.43
    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%
    42%
    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.354
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1316"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 24.4% · Safe to merge
    24.4%
    Repository