facebook / facebook/pyrefly

Python API / PyO3 bindings for embedding Pyrefly

Open
#3,964 10 comments 1 reaction 0 assignees View on GitHub
needs-discussion
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Summary

Would the project be interested in exposing a Python API for Pyrefly, similar to `mypy.api`?

Currently, the Python package is a CLI wrapper invoking pyrefly via `subprocess`. I'm building a python transpiler and wanted to use pyrefly in CI to verify the generated python code is valid. I had performance concerns calling subprocess as much as I wanted to; wondering if direct bindings exposed to the python api would be better? My guess is yes...

I pictured something like this but it's actually just an FFI to the rust code:

```python
import pyrefly

result = pyrefly.check(paths=["src"])
```

Before spending time on a prototype, I wanted to check whether maintainers would be open to this direction or had other suggestions. I'd love the chance to work on something like this :)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Python package's CLI wrapper and how it invokes Pyrefly through subprocess, then inspect the Rust code relevant to a possible PyO3 FFI. Clarify the maintainers' preferred direction and define whether completion means supporting a direct API such as pyrefly.check(paths=["src"]) for CI use.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.