Skip to content

Create python bindings for in process checks#4002

Draft
tylerriccio33 wants to merge 5 commits into
facebook:mainfrom
tylerriccio33:gh-3964-in-process-check
Draft

Create python bindings for in process checks#4002
tylerriccio33 wants to merge 5 commits into
facebook:mainfrom
tylerriccio33:gh-3964-in-process-check

Conversation

@tylerriccio33

Copy link
Copy Markdown

Summary

This draft PR is to pair #3964 and show an example of how the in process API could work, with bindings directly to the rust code via pyo3. I can't think of another way to do this without adding a new crate and pyo3, which could be undesirable from the dependency standpoint.

Perhaps this functionality should be made optional?

Fixes #3964

Test Plan

I add a simple rust test and a python test to go with the crate. I wanted the python test to capture the fact we have the pyrefly.toml file and the helper file which we import from. Another nice thing (which @yangdanny97 pointed out) is this plays off lsp mode so any future checks would be against the warm checker

If this direction is approved I'll of course drastically expand the test suite

def test_checker_resolves_imports_and_reports_errors(tmp_path):
    (tmp_path / "pyrefly.toml").write_text("")
    (tmp_path / "helper.py").write_text("def greet() -> int: ...\n")

    checker = pyrefly_api.Checker(project_root=str(tmp_path))

    diags = checker.check("from helper import greet\nx: str = greet()")
    assert [d.kind for d in diags] == ["bad-assignment"]

    assert checker.check("from helper import greet\ny: int = greet()") == []

FYI - I used claude to help me figure out how the playground worked, since I was having trouble determining a few things. Honestly never worked in codebase this size in rust

@meta-cla

meta-cla Bot commented Jul 1, 2026

Copy link
Copy Markdown

Hi @tylerriccio33!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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

Labels

1 participant