Skip to main content

Enable hinting for pyo3 extension modules by generating type and docstring stubs

Project description

pyo3-stubgen

pyo3-stubgen generates .pyi typing files for extension modules which were written in rust with pyo3.

It is designed to work for extension modules created in rust with pyo3 but should work with any compiled extension modules which include a __text_signature__ and optionally a __doc__ attribute for functions.

Despite flake8's recommendation to the contrary, pyo3_stubgen adds docstrings to the .pyi files so that IDEs can provide them in hover pop-ups.

You will need to manually add the typing information to the generated files as this is not included in any of the function attributes available and is just as dependent upon the semantics of your functions as on the technical implementation.

Note: Currently pyo3_stubgen only generates info for functions. Classes are on the to-do list.

Installation

Install via pip:

(.venv)/projectroot$ pip install pyo3-stubgen

Usage

Easiest from the command line:

(.venv)/projectroot$ stubgen MODULENAME OUTPUTLOCATION

See stubgen --help for more details

Alternatively via the python API. See the docs for more details.

Issues, Bugs, Ideas

Please contribute on github MusicalNinjas/pyo3-stubgen.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyo3_stubgen-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pyo3_stubgen-0.2.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pyo3_stubgen-0.2.0.tar.gz.

File metadata

  • Download URL: pyo3_stubgen-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyo3_stubgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1fe0ab59bf14e70b7a9592e06017f187d9fc27eafe51e52aa9e41e89472e7b2b
MD5 d17eeb7c2c11f36280e344f977cd8979
BLAKE2b-256 4c764501a0ca7af9be53861bcc91291eaf851ee27a528080227ccbdfa52b7b77

See more details on using hashes here.

File details

Details for the file pyo3_stubgen-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyo3_stubgen-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyo3_stubgen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a182cc95fa1d27f977215d4e3b9d198b62243c8315dd0f397fddeed243acd1
MD5 fd81d71ecc6422604befc6d11143ad76
BLAKE2b-256 9d0910eff57d93fa8430f4b5cb02d4ca3f418e925f8927e0357509b574e1e6e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page