This project has been archived by its maintainers, and is no longer receiving any updates.
pygenstub
pygenstub is a utility for generating stub files from docstrings in source files.
If the docstring of a function includes a sig field, the value of that field will be used to generate a stub by matching the types to the parameters in the same order.
For example, for the function given below:
def foo(a, b):
"""Do foo.
:sig: (int, str) -> None
"""
pygenstub will generate the following stub:
def foo(a: int, b: str) -> None: ...
pygenstub consists of a single source file which contains such signatures. You can check the stub file generated by running pygenstub on itself as an example.
Getting started
pygenstub runs on Python 3.6 and later versions. You can install the latest version from PyPI:
pip install pygenstub
Installation creates a script named pygenstub which can be used as follows:
pygenstub foo.py
This command will generate the file foo.pyi in the same directory as the input file. If the output file already exists, it will be overwritten.
If you download the source file, you can also run it directly without installing:
python pygenstub.py foo.py
If pygenstub is activated as a Sphinx extension (after sphinx.ext.autodoc), it will insert type comments into the docstring:
extensions = [
"sphinx.ext.autodoc",
"pygenstub"
]
As an example of the output, you can check the API documentation for pygenstub itself.
Getting help
The documentation is available on: https://pygenstub.readthedocs.io/
The source code can be obtained from: https://github.com/uyar/pygenstub
License
Copyright (C) 2016-2021 H. Turgut Uyar <uyar@tekir.org>
pygenstub is released under the GPL license, version 3 or later. Read the included LICENSE.txt for details.
Metadata
Release files for pygenstub 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygenstub-2.0.1.tar.gz | 24.8 kB | Without provenance | Details for pygenstub-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygenstub-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for pygenstub-2.0.1-py3-none-any.whl |
Total release size: 49.2 kB
Release files / pygenstub-2.0.1.tar.gz
| Download URL | pygenstub-2.0.1.tar.gz |
|---|---|
| Size | 24.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e72af6765731e9b3c4dfef8461960d83c8046922cfb3b486c129b23b8112b7f
|
|
BLAKE2b-256 checksum How to use checksums |
08ef19ff0f6c27ef4b64f78b6a677bf790e597b277f7155a9f13caf06757854c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.1 Linux/5.8.0-43-generic
|
Release files / pygenstub-2.0.1-py3-none-any.whl
| Download URL | pygenstub-2.0.1-py3-none-any.whl |
|---|---|
| Size | 24.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c63c6dd1df9dad13d9fcbc9e55ab0367d2bad7fc2ce1063d4a8c0d93153b6803
|
|
BLAKE2b-256 checksum How to use checksums |
eea7693dc043b83afd26462889cb4c42431e42248d66bfe5c27d829077f402e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.1 Linux/5.8.0-43-generic
|
Security for pygenstub 2.0.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.