MusicalNinjas / pyo3-stubgen

Generates .pyi files from external .so libraries built using pyo3
https://musicalninjas.github.io/pyo3-stubgen/
MIT License
3 stars 2 forks source link

Use type information from parseable docstrings? #9

Open cgevans opened 2 weeks ago

cgevans commented 2 weeks ago

For some styles of docstrings, particularly numpydoc, it may be possible to use the docstring to add type information to the signature, and a return type. For modules with appropriately-formatted docstrings, this could allow an almost-complete typed stub file with minimal manual editing.

The numpydoc package supports parsing of numpydoc docstrings; there may be other packages for other styles. It may be that further parsing would be required:

MusicalNinjaDad commented 2 weeks ago

That's a really good idea @cgevans.

I can think of a few (more) places where similar functionality is available:

In my experience each of those need very specific and exact formatting to work.

I'd suggest for now just handling the case which you need and we can work on extending to other situations over time(?)

pawamoy commented 2 weeks ago

If you decide to use Griffe, let me know, I can help :)