stouputils.continuous_delivery.stubs module#

This module contains utilities for generating stub files using stubgen.

  • generate_stubs: Generate stub files for a Python package using stubgen

  • stubs_full_routine: Generate stub files for a Python package

generate_stubs(
package_name: str,
extra_args: str = '--include-docstrings --include-private',
) int[source]#

Generate stub files for a Python package using stubgen.

Note: stubgen generates stubs in the ‘out’ directory by default in the current working directory.

Parameters:
  • package_name (str) – Name of the package to generate stubs for.

  • extra_args (str) – Extra arguments to pass to stubgen. Defaults to “–include-docstrings –include-private”.

Returns:

Return code of the os.system call.

Return type:

int

clean_stubs_directory(
output_directory: str,
package_name: str,
) None[source]#

Clean the stubs directory by deleting all .pyi files.

Parameters:
  • output_directory (str) – Directory to clean.

  • package_name (str) – Package name subdirectory. Only cleans output_directory/package_name.

stubs_full_routine(package_name: str, output_directory: str = 'typings', extra_args: str = '--include-docstrings --include-private', clean_before: bool = False, generate_stubs_function: ~collections.abc.Callable[[str, str], int] = <function generate_stubs>, clean_stubs_function: ~collections.abc.Callable[[str, str], None] = <function clean_stubs_directory>) None[source]#

Generate stub files for a Python package using stubgen.

Note: stubgen generates stubs in the ‘out’ directory by default in the current working directory.

Parameters:
  • package_name (str) – Name of the package to generate stubs for.

  • output_directory (str) – Directory to clean before generating stubs. Defaults to “typings”. This parameter is used for cleaning the directory before stub generation.

  • extra_args (str) – Extra arguments to pass to stubgen. Defaults to “–include-docstrings –include-private”.

  • clean_before (bool) – Whether to clean the output directory before generating stubs. Defaults to False.

  • generate_stubs_function (Callable[[str, str], int]) – Function to generate stubs. Defaults to generate_stubs().

  • clean_stubs_function (Callable[[str], None]) – Function to clean the stubs directory. Defaults to clean_stubs_directory().

Raises:

Exception – If stub generation fails.