Skip to content

Add experimental programmatic API for Monty - #4866

Open
yangdanny97 wants to merge 5 commits into
facebook:mainfrom
yangdanny97:monty-api
Open

Add experimental programmatic API for Monty#4866
yangdanny97 wants to merge 5 commits into
facebook:mainfrom
yangdanny97:monty-api

Conversation

@yangdanny97

@yangdanny97 yangdanny97 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

For https://www.github.com/pydantic/monty/pull/501

Something about how Monty can't depend on a crate that's a GH revision hash.

I guess after this gets merged you guys need to publish it, but IDK how to do that

Test Plan

I ran all the tests at some point but after the demise of my Macbook Pro I now use a Macbook Air which has no fans so I'm reluctant to risk running the test suite and overheating it

so, TLDR trust CI

@meta-codesync

meta-codesync Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D119299371. (Because this pull request was imported automatically, there will not be any future comments.)

@yangdanny97 yangdanny97 removed their assignment Sep 9, 2026
@github-actions

This comment has been minimized.

@kinto0 kinto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat confusing API for an unclear use-case. if we ever merge something like this, I think it needs to be simple and have clear documentation.

I also don't see a disclaimer that this is experimental anywhere in the code

Comment thread pyrefly/lib/embed.rs Outdated
/// when `None`) over the in-memory modules named in `modules`. Only those module
/// names are importable between the supplied sources; everything else resolves to
/// the bundled typeshed. No interpreter is queried.
pub fn new(python_version: Option<&str>, modules: &[&str]) -> Result<Self, String> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unclear what modules is. is this every module this API can check?

the "config" is just a python_version. I imagine we will need a lot more config at some point. the config options that are essential here depends on the use-case. should we use the full ConfigFile struct?

@yangdanny97 yangdanny97 Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should overdo it now - the full config is excessive IMO since it's just a REPL

we can add it later if we need it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modules for Monty is 2 files, 1 is the "file" containing the REPL, 2 is the stubs that Monty injects

Comment thread pyrefly/lib/embed.rs Outdated
/// Type check the `target` module, returning diagnostics for it only.
///
/// `files` supplies the current source for each in-memory module (each
/// `(module_name, source)`); every name must have been declared in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every name must have been declared

this is a confusing API and I don't think it can land like this

@yangdanny97

Copy link
Copy Markdown
Collaborator Author

In my view this is in the same category as glean's API or the WASM stuff, where it should be undocumented until we refine the API enough and decide to publicize it

The main purpose of merging it is so that Monty can actually release a version that uses Pyrefly

@yangdanny97

Copy link
Copy Markdown
Collaborator Author

Cleaned up a few things

@github-actions github-actions Bot added size/l and removed size/l labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants