A stub generator for pybind11 modules, built with Griffe and Jinja2.
Generates precise .pyi type stubs for C++/pybind11 codebases. Originally built to support
Endstone's pybind11 bindings, it works equally well
for any pybind11 project.
- Griffe-based introspection for robust parsing of pybind11 extensions
- Jinja2 templating with fully customizable
.pyitemplates - Accurate handling of overloads, enums, default values, and pybind11-bound C++ types
- Deterministic, reproducible output for large codebases
- PEP 561 compliant (works with mypy, pyright, and other type checkers)
pip install endstone-stubgenOr with uv:
uv add endstone-stubgenGenerate stubs for a module:
stubgen <module_name>Specify an output directory:
stubgen <module_name> -o stubs/Dry run (parse and report errors without writing files):
stubgen <module_name> --dry-runstubgen endstone -o stubs/Produces:
stubs/
endstone/
__init__.pyi
command.pyi
event.pyi
...
git clone https://github.com/EndstoneMC/stubgen.git
cd stubgen
uv sync
uv run ruff check src/- Add changes under
## [Unreleased]inCHANGELOG.md - Go to Actions > Release > Run workflow
- Enter the version (e.g.
0.2.0) and run
The workflow validates the version, updates pyproject.toml and CHANGELOG.md, creates a git tag and GitHub release, builds, publishes to PyPI, and attaches artifacts.
Use dry run to preview without making changes.