Added automatic type stub generation with pyo3-introspection#2940
Added automatic type stub generation with pyo3-introspection#2940varchasgopalaswamy wants to merge 4 commits intoPyO3:mainfrom
Conversation
|
[for context I am the main person working on introspection in Pyo3] Thank you for this! I am not sure pyo3-introspection in its released version is ready to be part of a build pipeline, there are still to many issues. I am scared it will move people out of the feature even if it's quite promising. A good first step might a new For context, I also have a draft commit adding a |
|
Yes, I think feature gating it, maybe behind a CLI arg might be a good idea to let people know it's experimental and let them opt in. But my two cents is that exposing it even just as a preview feature through maturin would make it a lot easier for folks to give feedback! Since pyo3-introspection is lib only, it requires a bit of work to get it to start generating stubs. That said, it's working pretty well so far! |
Yes! But I am afraid the missing features will be frustrating to the people trying and I guess most of the feedback will be elements still on the TODO list or already fixed in the unreleased version. Waiting a few month for at least the next pyo3 release seems a bit better to me. |
Fair point. I guess we can leave this PR open so people can test-drive the introspection changes, and re-visit this once more of the TODOs are dealt with! |
This PR adds a basic mechanism for type stub generation with
pyo3-introspection.Perhaps there is a better way to do it, but the most obvious way to get the stubs into the wheel seemed to be by
compile..so/.dllfile ends upBuildArtifactbinding_generatorappend the stubs into theadditional_filesfield that it carries around to put python files into the wheelI've currently just implemented the last step for
pyo3_bindingbut I guess there's no reason why it couldnt be applied elsewhere. I suppose the stubs could also be generated during the binding generation rather than during compile, but I think it's nice to be able to see the generated stubs and be able to check that they look good before they get stuffed into a wheel.