Skip to main content

Generate python stub files for code completion in IDEs for nanobind modules.

Project description

nanobind-stubgen PyPI

Generate Python stub files (pyi) for code completion in IDEs for nanobind modules.

Installation

pip install nanobind-stubgen

Usage

Nanobind stubgen uses the inspect module to reverse engineer the module structure and detects nanobind types. The doc string of the nanobind types contains the function signature, which will be used to create the stub files.

To create pyi files for a module, first install the module and call nanobind-stubgen with the module name as first argument. Here is an example on how to generate stubs for nanogui:

nanobind-stubgen nanogui

It is possible to change the output path (by default it is the current directory) by specifying the parameter --out. To create the pyi files directly in the nanogui package directory, the following command can be used (note the changing python version):

nanobind-stubgen nanogui --out venv/lib/python3.9/site-packages

Limitations

  • The stub generator does not use the nanobind project, but the actual compiled python module. This means, that the generator can only detect module and function information that has been writen into the __doc__ string by nanobind.
  • Only some imports in the pyi files are added
  • Method overloading is supported but only to some extent

Help

positional arguments:
  module             Module to create stubs (e.g. nanogui).

optional arguments:
  -h, --help         show this help message and exit
  --package PACKAGE  Optional package path to import module from.
  --out OUT          Output path for the generated pyi files.

About

MIT License

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

nanobind_stubgen-0.1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nanobind_stubgen-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nanobind_stubgen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae2c75fd6ea9b4a8b2eef5131b263804f1dce2f2656fcc5dbb08ad8099f83cc6
MD5 d03766fc87ef75620a92f58e93868a5b
BLAKE2b-256 58d05dd8de13f4a9e91d096d80dc0a58d7b9d3cb53ba3b0ce41aa3e1e555bc04

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