Skip to content

Resolve generated stubs alongside editable packages - #4535

Open
ting-hong-shieh wants to merge 1 commit into
facebook:mainfrom
ting-hong-shieh:fix/2859-generated-stubs
Open

Resolve generated stubs alongside editable packages#4535
ting-hong-shieh wants to merge 1 commit into
facebook:mainfrom
ting-hong-shieh:fix/2859-generated-stubs

Conversation

@ting-hong-shieh

Copy link
Copy Markdown
Contributor

Summary

  • preserve typed namespace roots when a later search root contains an editable regular package
  • use those typed roots as overlays when resolving package submodules
  • retain the regular package's __init__.py as the package module
  • add resolver-level and end-to-end regressions for generated extension stubs

Root cause

Generated stubs installed next to an extension module form an implicit namespace package. When an editable source directory later supplied the package's __init__.py, normal regular-package precedence discarded the earlier namespace root, so submodules such as _core.pyi were no longer visible.

The overlay is limited to namespace roots containing py.typed, preserving existing behavior for ordinary implicit namespace packages.

User impact

Editable installs can expose their source package and generated extension stubs at the same time, so imported native APIs retain their declared types.

Testing

  • cargo test module::finder::tests (71 tests)
  • cargo test test_editable_install_generated_stub_overlay
  • formatter and Clippy through test.py

Fixes #2859

Keep generated stubs from typed namespace roots available when a later editable source directory provides the regular package initializer.
@meta-cla meta-cla Bot added the cla signed label Aug 13, 2026
@ting-hong-shieh
ting-hong-shieh marked this pull request as ready for review August 13, 2026 08:40
@meta-codesync

meta-codesync Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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

@ting-hong-shieh

Copy link
Copy Markdown
Contributor Author

The Meta Linter check is currently reporting Action Required, but the internal details are not accessible to external contributors. Could someone with access share the failing diagnostic so I can address it? Thanks!

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.

Generated typestubs are not found in an editable install

2 participants