Expand description
§monty-typeshed
The vendored typeshed subset that powers type checking in Monty.
Monty implements a deliberately small subset of Python’s stdlib. Its type
checker (the monty-type-checking
crate, powered by ty) therefore needs stubs that
describe Monty’s runtime surface rather than CPython’s: code using an
unsupported builtin or stdlib module should fail type checking up front, not
pass the checker and then fail at runtime. This crate vendors only the stubs
for what Monty supports, with unsupported functions and classes filtered out.
Originally derived from ruff’s
ty_vendored
crate.
§Layout
vendor/typeshed/— the vendored stubs, derived from upstream typeshed at the commit recorded invendor/typeshed/source_commit.txt(exposed asSOURCE_COMMIT). Do not edit these files manually — they are overwritten wholesale by the update script.custom/— hand-written stubs that override or supplement upstream files where Monty’s surface intentionally differs (e.g.asyncio,os,sys,unicodedata). The update script copies them intovendor/typeshed/stdlib.update.py— clones upstream typeshed, filters the stubs down to the builtins and modules Monty supports (whitelists in the script mirrorcrates/monty/src/builtins/), and applies thecustom/overrides. Run it viamake update-typeshedfrom the workspace root.build.rs— zips the vendored stubs into the compiled binary at build time, so Monty ships type checking with no files on disk.
§API
The crate exposes a single entry point: file_system() returns a static
ruff_db VendoredFileSystem over the zipped stubs, which
monty-type-checking uses as the search path for stdlib module resolution.
let typeshed = monty_typeshed::file_system();
assert!(typeshed.exists("stdlib/builtins.pyi"));§Monty crates
monty— the core interpreter: Python parser, bytecode VM, and sandbox.monty-types— the shared boundary data types (values, exceptions, OS calls, resource limits) hosts use without linking the interpreter.monty-fs— host-side filesystem mounts: maps virtual sandbox paths to real host directories.monty-runtime— themontybinary: REPL, file runner, and subprocess worker mode.monty-pool— an elastic pool of crash-isolatedmontyworker subprocesses.monty-proto— the protobuf wire protocol spoken between pool parents and workers.monty-type-checking— type checking of sandboxed code, powered by ty.monty-typeshed— the trimmed typeshed stubs describing the stdlib subset Monty implements. this cratemonty-macros— the proc macros behindmonty’s argument parsing.
Constants§
- SOURCE_
COMMIT - The source commit of the vendored typeshed.