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

Overview

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.

You might also like...
A utility that makes it easy to work with Python projects containing lots of packages, of which you only want to develop some.

Mixed development source packages on top of stable constraints using pip mxdev [mɪks dɛv] is a utility that makes it easy to work with Python projects

🍰 ConnectMP - An easy and efficient way to share data between Processes in Python.
🍰 ConnectMP - An easy and efficient way to share data between Processes in Python.

ConnectMP - Taking Multi-Process Data Sharing to the moon 🚀 Contribute · Community · Documentation 🎫 Introduction : 🍤 ConnectMP is the easiest and

Local backup made easy, with Python and shutil

KTBackup BETA Local backup made easy, with Python and shutil Features One-command backup and restore Minimalistic (only using stdlib) Convenient direc

Easy compression and extraction for any compression or archival format.
Easy compression and extraction for any compression or archival format.

Tzar: Tar, Zip, Anything Really Easy compression and extraction for any compression or archival format. Usage/Examples tzar compress large-dir compres

Search, generate & deliver Msfvenom payloads in an quick and easy way
Search, generate & deliver Msfvenom payloads in an quick and easy way

Goal Search, generate & deliver payloads in an quick and easy way Be as simple as possible BUT with all msfvenom payloads. Ever lost time searching th

Application for easy configuration of swap file and swappiness priority in slackware and others linux distributions.

Swap File Program created with the objective of assisting in the configuration of swap file in Distributions such as Slackware. Required packages: pyt

Regression Metrics Calculation Made easy

Regression Metrics Mean Absolute Error Mean Square Error Root Mean Square Error Root Mean Square Logarithmic Error Root Mean Square Logarithmic Error

Helpful functions for use alongside the rich Python library.

🔧 Rich Tools A python package with helpful functions for use alongside with the rich python library. 󠀠󠀠 The current features are: Convert a Pandas

A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use that mirror

Kali Mirror Finder Using Single Python File A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use tha

Comments
  • Render some magic methods for classes

    Render some magic methods for classes

    Render magic methods if the signature of the method differs significantly from the parent method. Also made logic for metaclass rendering more correct.

    opened by alexdrydew 0
  • Aliases support

    Aliases support

    Added support for objects' module and qualname aliases.

    Examples when this feature is required:

    • pandas.DataFrame.__module__ is pandas.core.frame. It is possible to import DataFrame from pandas.core.frame instead of pandas but undesired
    • types.ModuleType.__module__ is builtins and types.ModuleType.__qualname__ is module. Attempt to import module from builtins leads to ImportError.

    The feature is implemented by passing a python module path as an argument. This module should define DESCRIBED_OBJECTS dictionary at the top level, which is a mapping from python objects to tuples consisting of module name and qualname for the described object.

    enhancement 
    opened by alexdrydew 0
Releases(v0.0.3)
  • v0.0.3(Jul 5, 2022)

    • Stub generation for metaclasses support.
    • Added described_objects option for stub generation which enables support for objects with predefined module name and qualname. This is required for correct stub generation in cases when object has a wrong __module__ (e.g., contextvars.ContextVar has __module__ builtins but in reality must be imported from contextvars) or can't be accessed by qualname directly (e.g., ModuleType which __qualname__ has "module" value).
    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Oct 7, 2021)


    • TypeVar support
    • Renamed AST to RepresenationsTree
    • Better module dependencies resolving
    • Wrong namespaces in functions arguments default values bug fixed
    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Aug 24, 2021)

Owner
Toloka
Data labeling platform for ML
Toloka
These scripts look for non-printable unicode characters in all text files in a source tree

find-unicode-control These scripts look for non-printable unicode characters in all text files in a source tree. find_unicode_control.py should work w

Siddhesh Poyarekar 25 Aug 30, 2022
Simple code to generate a password for your account!

Password-Generator Simple code to generate a password for your account! Password Generator for passwords for your accounts or anything else! This code

DEEM 1 Jun 05, 2022
Kanye West Lyrics Generator

aikanye Kanye West Lyrics Generator Python script for generating Kanye West lyrics Put kanye.txt in the same folder as the python script and run "pyth

4 Jan 21, 2022
A morse code encoder and decoder utility.

morsedecode A morse code encoder and decoder utility. Installation Install it via pip: pip install morsedecode Alternatively, you can use pipx to run

Tushar Sadhwani 2 Dec 25, 2021
ecowater-softner is a Python library for collecting information from Ecowater water softeners.

Ecowater Softner ecowater-softner is a Python library for collecting information from Ecowater water softeners. Installation Use the package manager p

6 Dec 08, 2022
This tool analyzes the json files generated by stream-lnd-htlcs to find hidden channel demand.

analyze_lnd_htlc Introduction Rebalancing channels is an important part of running a Lightning Network node. While it would be great if all channels c

Marimox 4 Dec 08, 2022
一款不需要买代理来减少扫网站目录被封概率的扫描器,适用于中小规格字典。

PoorScanner使用说明书 -工具在不同环境下可能不怎么稳定,如果有什么问题恳请大家反馈。说明书有什么错误的地方也大家欢迎指正。 更新记录 2021.8.23 修复了云函数主程序 gitee上传文件接口写错了的BUG(之前把自己的上传地址写死进去了,没从配置文件里读) 更新了说明书 PoorS

14 Aug 02, 2022
Teleport Ur Logs with Love

Whatever you pipe into tull, will get a unique UUID and the data gets stored locally - accessible via a flask server with simple endpoints. You can use ngrok or localtunnel then to share it outside L

Lokendra Sharma 11 Jul 30, 2021
A simple tool to move and rename Nvidia Share recordings to a more sensible format.

A simple tool to move and rename Nvidia Share recordings to a more sensible format.

Jasper Rebane 8 Dec 23, 2022
✨ Voici un code en Python par moi, et en français qui permet de générer du texte Lorem.

Lorem Gen ❗ Voici un code en Python par moi, et en français qui permet de générer du texte Lorem. Dépendences : pip install lorem_text 💖 Enjoy 🎫 Mon

MrGabin 3 Jun 07, 2021
Format Norminette Output!

Format Norminette Output!

7 Apr 19, 2022
Local backup made easy, with Python and shutil

KTBackup BETA Local backup made easy, with Python and shutil Features One-command backup and restore Minimalistic (only using stdlib) Convenient direc

kelptaken 1 Dec 27, 2021
Runes - Simple Cookies You Can Extend (similar to Macaroons)

Runes - Simple Cookies You Can Extend (similar to Macaroons) is a paper called "Macaroons: Cookies with Context

Rusty Russell 22 Dec 11, 2022
A tool written in python to generate basic repo files from github

A tool written in python to generate basic repo files from github

Riley 7 Dec 02, 2021
Parse URLs for DOIs, PubMed identifiers, PMC identifiers, arXiv identifiers, etc.

citation-url Parse URLs for DOIs, PubMed identifiers, PMC identifiers, arXiv identifiers, etc. This module has a single parse() function that takes in

Charles Tapley Hoyt 2 Feb 12, 2022
A python script to generate wallpaper

wallpaper eits Warning You need to set the path to Robot Mono font in the source code. (Settings are in the main function) Usage A script that given a

Henrique Tsuyoshi Yara 5 Dec 02, 2021
general-phylomoji: a phylogenetic tree of emoji

general-phylomoji: a phylogenetic tree of emoji

2 Dec 11, 2021
Python based tool to extract forensic info from EventTranscript.db (Windows Diagnostic Data)

EventTranscriptParser EventTranscriptParser is python based tool to extract forensically useful details from EventTranscript.db (Windows Diagnostic Da

P. Abhiram Kumar 24 Nov 18, 2022
A Randomizer Oracle

Tezos Randomizer Tezod Randomizer "Oracle". It's a smart contract that you can call to get a random number between X and Y (for now). It uses entropy

Asbjorn Enge 19 Sep 13, 2022
EthTx - Ethereum transactions decoder

EthTx - Ethereum transactions decoder Installation pip install ethtx Requirements The package needs a few external resources, defined in EthTxConfig o

398 Dec 25, 2022