Skip to main content

Generates `.pyi` files from Cython modules in a given package directory.

Project description

stubgen-pyx

Stub generation for Cython code.

Installation

Install the package with pip install stubgen-pyx.

Usage

From the command line:

stubgen-pyx /path/to/package

Or from Python:

import stubgen_pyx
stubgen_pyx.stubgen("/path/to/package")

Why?

Cython is a popular Python extension language, but introspection for Cython modules is often limited. .pyi files are a common way to provide type hints for Python code that cannot be easily analyzed statically.

Why not mypy?

mypy is a static type checker for Python that can generate .pyi files for extension modules at a pretty good level of accuracy. However, it's not designed to utilize embedded information about Cython module members - this leaves the .pyi files quite limited.

Limitations

  • cimport-ed modules with types that leak into the stub file (by way of function signatures, for example) do not have their imports followed in the stub file. As a workaround, you can set a __cimport_types__ list or tuple of module types that you want exposed to the stub file.

  • This is only designed to be a pretty good approximation of Python-public members in a Cython module. It's still very much a work in progress and may produce inaccurate results. If you notice any bugs or have any suggestions, please open an issue.

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

If you're not sure about the file name format, learn more about wheel file names.

stubgen_pyx-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file stubgen_pyx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: stubgen_pyx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for stubgen_pyx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6209f0697e19db4e951355521497885be0b5eeb7489da82b3a048f40d8dc0ea8
MD5 52a40e51962fc9aca3a8c727456a6aae
BLAKE2b-256 13d983ddd0859b7912c500e2c7cace5cfb5fcc60482b477235158395240373be

See more details on using hashes here.

Supported by

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