Skip to main content

Tool for generating python stubs

Project description

Stubmaker

Stubmaker is an easy-to-use tool for generating python stubs.

Requirements

  • Stubmaker is to be run under Python 3.7.4+
  • No side effects during module imports
  • Must contain __all__ (this restriction will be removed in upcomming releases)

How to install

pip install stubmaker
stubmaker --help

Usage example

Imagine you have a package with the following structure:

package
-> __init__.py

Contents of __init__.py:

__all__ = ['sleep_for']
from time import sleep


def some_decorator(func):
    return func


@some_decorator
def sleep_for(amount: float) -> None:
    sleep(amount)

There is a script that calls sleep_for method but passes wrong arguments:

from package import sleep_for

sleep_for(123, 123)

Due to dynamic nature of decorators static analysers (such as mypy) may not raise an error while checking the script:

>> mypy __main__.py

Success: no issues found in 1 source file

Stubs exist to help you! Stubmaker will provide stubs for your package so that its users can find the error using mypy:

>> stubmaker --module-root package --src-root <path to package>/package --output-dir <path to package>/package
>> mypy __main__.py

__main__.py:3: error: Too many arguments for "sleep_for"
Found 1 error in 1 file (checked 1 source file)

License

© YANDEX LLC, 2020-2021. Licensed under the Apache License, Version 2.0. See LICENSE file for more details.

Project details


Download files

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

Source Distribution

stubmaker-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

stubmaker-0.1.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file stubmaker-0.1.0.tar.gz.

File metadata

  • Download URL: stubmaker-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for stubmaker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4905835c8a935c2da44c93ae782bbe53fa5f49142e0bc7fa550704c4a775856f
MD5 6c70db063d4b88fa8e766b7bac6856f9
BLAKE2b-256 eaee4a532b81e9932d98c7b2fa526128e24d1d84792865ca53584bcf5427c3da

See more details on using hashes here.

File details

Details for the file stubmaker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stubmaker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for stubmaker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a08ed4c8f14b464c440160428753bb7f2574c726cd6a9f1121663f1c55cabb69
MD5 3504f65f638edadc855e17a9e4d30574
BLAKE2b-256 8e196e45f777246d6cf4763afadaec0694243a2c9277d2ee5ed4d12d6bea21c3

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