← Back to Pull requests

Implement `os.path` #1000

Closed
unknown closed this pull request without merging on Oct 10, 2026 14:11 UTC
View on GitHub
unknown unknown commented on Oct 09, 2026 10:10 UTC
Author

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

Summary by cubic


Implements os.path (also importable as posixpath) as a module reached through os. Pure functions like join, split, normpath, and relpath run the posixpath algorithms on bytes so str, bytes, and pathlib.Path share one code path; host-backed functions like exists, isfile, getsize, lexists, samefile, realpath (including strict=True), and expanduser reuse existing Path/os host calls, chaining a second call where a function needs one. The path model is always POSIX regardless of host OS. Vendors upstream posixpath/genericpath stubs, with os/path.pyi pinning os.path to posixpath. expandvars charges its output growth to the memory budget: each capacity doubling is preflighted, so amplifying substitutions raise MemoryError at the soft limit instead of building the whole result.

os.stat, os.listdir, os.chdir, and the os.path functions built on them now accept int paths and fail them as closed file descriptors, matching CPython: OSError EBADF, False from the predicates, and OverflowError outside C int.

Hosts must now answer the extra chained calls (one OsCall at a time follows the reply); no other host changes are needed.

Bug fixes

  • import a.b now loads a.b but binds a like CPython; aliased imports still bind the submodule. Failed dotted imports name the first missing component, or the module that is not a package.

  • Heap-allocated bytes now compare and order like literals.

  • commonprefix returns the smallest element itself instead of a copy.
  • Limitations

  • sameopenfile is not implemented: it needs a host call no existing call provides.

  • ismount reports every existing path as a mount point, since the sandbox cannot see the host's mount layout.

  • Host-backed functions take str/PathLike[str] only, with no bytes paths; ints fail as closed descriptors rather than reaching real fds. Documented in docs/limitations/os.md.
  • <sup>Written for commit 3638f518e6b79da994c15987865ebe4021676380. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1000?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/1000?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1000&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: 404 lines (+303 / -101) across 5 files Reviewer: samuelcolvin Review duration: 1681m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 404 lines diff across 5 files
    0.50
    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.359
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1000"
    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: 49.8% (MEDIUM) · Higher = larger blast radius
    49.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: 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: 19.7% · Safe to merge
    19.7%
    Repository