facebook / facebook/pyrefly

Generated typestubs are not found in an editable install

Open
#2,859 2 comments 0 reactions 0 assignees View on GitHub
help wanted typeshed
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

When typestubs are generated for a Python extension, they are not found in an editable install, although they are installed to the appropriate location in site-packages along with the DSO for the extension.

When the same package is installed in a non-editable context, typestubs are found correctly and type errors reported as expected.

The linked repository https://github.com/jbcoe/xyz-generated-typestubs has a minimal (but still not tiny) reproduction where two script can be run to illustrate the problem.

`./check_in_project.sh` incorrectly returns type errors because it cannot find type stubs.

`./check_out_of_project.sh` correctly returns type errors in a non-project file that tries to use a function with the wrong types.

I suspect that pyrefly’s import discovery logic for editable installs needs to be updated to account for generated typestubs located alongside the extension's binary.

## Note
A similar bug was raised with `ty` https://github.com/astral-sh/ty/issues/2911. That was fixed with a simple (if somewhat non-obvious) config change.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.