About
Static analysis tools and IDE usually struggle to understand python binary extensions.
pybind11-stubgen generates stubs for python extensions to make them less opaque.
While the CLI tool includes tweaks to target modules compiled specifically with pybind11 but it should work well with modules built with other libraries.
# Install
pip install pybind11-stubgen
# Generate stubs for numpy
pybind11-stubgen numpy
Usage
pybind11-stubgen [-h]
[-o OUTPUT_DIR]
[--root-suffix ROOT_SUFFIX]
[--ignore-invalid-expressions REGEX]
[--ignore-invalid-identifiers REGEX]
[--ignore-unresolved-names REGEX]
[--ignore-all-errors]
[--enum-class-locations REGEX:LOC]
[--numpy-array-wrap-with-annotated|
--numpy-array-use-type-var|
--numpy-array-remove-parameters]
[--print-invalid-expressions-as-is]
[--print-value-comments]
[--print-safe-value-reprs REGEX]
[--exit-code]
[--stub-extension EXT]
MODULE_NAME [MODULE_NAMES ...]
Contributing
During development, you may need to update the reference stubs in tests/stubs. This can be done locally using a convenience tox configuration. Ensure that all Python interpreters required by the test suite are available in your environment. For example, you can install them via uv:
uv python install 3.10 3.11 3.12 3.13
To enable the repository hooks locally:
uv sync
uv run pre-commit install
To regenerate the reference stubs run:
uv venv
source .venv/bin/activate
uv tool install tox --with tox-uv
uv run tox
Release files for pybind11-stubgen 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pybind11_stubgen-3.0.0.tar.gz | 33.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pybind11_stubgen-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.5 kB
Release files / pybind11_stubgen-3.0.0.tar.gz
| Download URL | pybind11_stubgen-3.0.0.tar.gz |
|---|---|
| Size | 33.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0a908ae99204e201a5148c17dc3cb789021a339ab9dc1d0517a23a87490204c
|
|
BLAKE2b-256 checksum How to use checksums |
570ac53a6d5300a2f9b7a11901a581e73bf81e00cce3053ce28b9b26e5cdd095
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / pybind11_stubgen-3.0.0-py3-none-any.whl
| Download URL | pybind11_stubgen-3.0.0-py3-none-any.whl |
|---|---|
| Size | 39.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
859b7b7dbd31d00f722f19152216b5506e8a5d3fdf586944de0cade80f972298
|
|
BLAKE2b-256 checksum How to use checksums |
ba3b16552e13615e8ee120338b2121642d5f0eeee7736e98f95c842d3cc83191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency log