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
-
cpdef-ed module and class members are only partially supported. They are included in the generated.pyifiles, but their type hints are incomplete (namely, they're given the typeobject). As a workaround, you can set a__annotations__dictionary in the module or class definition to manually specify the annotations you want to overlay on the stub file. -
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 which you want to import in the stub file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stubgen_pyx-0.1.0.tar.gz.
File metadata
- Download URL: stubgen_pyx-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c64d7d46fffb0a4598842a4d926c73d934f1876cf6683eab9b7d440e053eec
|
|
| MD5 |
7b79b54038950f9e897767e5528d3f8e
|
|
| BLAKE2b-256 |
b6137ea3d669728ad54c911e699fc6eae35852fb838f1e55b640cc561693c701
|
File details
Details for the file stubgen_pyx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stubgen_pyx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aea8421774faeca722db658cab027c3cceeda141a6788ae96abc22f54783a667
|
|
| MD5 |
ec9ae56806f842c054ce168926087500
|
|
| BLAKE2b-256 |
21b3f8ff919e8de8e5860e720d6c412b0ba7595f577a79ffdb48a9d2da36db9a
|