Stubdoc

Latest version: v0.1.12

Safety actively analyzes 681866 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.1.12

What's Changed
* Adapt generation of callable names to be able to detect built-in functionstions by tobiasah in https://github.com/simon-ritchie/stubdoc/pull/7

New Contributors
* tobiasah made their first contribution in https://github.com/simon-ritchie/stubdoc/pull/7

**Full Changelog**: https://github.com/simon-ritchie/stubdoc/compare/0.1.11...0.1.12

0.1.11

The stubdoc library now supports a top-level class docstring.

Related issue

5

Examples

Original module code:

py
from random import randint

sample_int: int = 100


def sample_func(a: int, b: str) -> bool:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Parameters
----------
a : int
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
b : str
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Returns
-------
c : bool
Ut enim ad minim veniam, quis nostrud exercitation.
"""
return True


class SampleClass:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam.
"""

def __init__(self) -> None:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
"""

property
def sample_property(self) -> int:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Returns
-------
d : int
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""
return randint(0, 100)


Original stub file (create with the mypy command):

py
sample_int: int

def sample_func(a: int, b: str) -> bool: ...

class SampleClass:
def __init__(self) -> None: ...
property
def sample_property(self) -> int: ...


After the stubdoc command (`$ stubdoc -m samples/sample.py -s out/samples/sample.pyi`) stubfile becomes as follows:

py
sample_int: int

def sample_func(a: int, b: str) -> bool:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Parameters
----------
a : int
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
b : str
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Returns
-------
c : bool
Ut enim ad minim veniam, quis nostrud exercitation.
"""

class SampleClass:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam.
"""
def __init__(self) -> None:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
"""
property
def sample_property(self) -> int:
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Returns
-------
d : int
ed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""

0.1.8

This release includes the following pull request: https://github.com/simon-ritchie/stubdoc/pull/3

Contributed by CSchulzeTLK

0.1.7

This release includes the following pull request: https://github.com/simon-ritchie/stubdoc/pull/2

Contributed by CSchulzeTLK

0.1.6

0.1.5

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.