stubber.stubber

Create, Process, and Maintain stubs ✏️ for MicroPython

Module Contents

Functions

stubber_cli(ctx, verbose=False, debug=False)

cli_clone(path: Union[str, pathlib.Path])

Clone/fetch the micropython repos locally.

cli_fetch(path: Union[str, pathlib.Path], tag: Optional[str] = None)

Switch to a specific version of the micropython repos.

cli_stub(source: Union[str, pathlib.Path])

Create or update .pyi type hint files.

cli_minify(ctx, source: Union[str, pathlib.Path], target: Union[str, pathlib.Path], keep_report: bool, diff: bool, cross_compile: bool, all: bool) → int

Minify createstubs*.py.

cli_get_frozen(stub_folder: str = config.stub_path.as_posix(), version: str = '', pyi: bool = True, black: bool = True)

Get the frozen stubs for MicroPython.

cli_get_lobo(stub_folder: str = config.stub_path.as_posix(), pyi: bool = True, black: bool = True)

Get the frozen stubs for Lobo-esp32.

cli_get_core(stub_folder: str = config.stub_path.as_posix(), pyi: bool = True, black: bool = True)

Download core CPython stubs from PyPi.

cli_docstubs(path: str = config.repo_path.as_posix(), target: str = config.stub_path.as_posix(), verbose: bool = False, black: bool = True, basename='micropython')

Build stubs from documentation.

cli_update_fallback(version: str, stub_folder: str = config.stub_path.as_posix())

Update the fallback stubs.

Attributes

log

VERSION_LIST

stubber.stubber.log
stubber.stubber.stubber_cli(ctx, verbose=False, debug=False)
stubber.stubber.cli_clone(path: Union[str, pathlib.Path])

Clone/fetch the micropython repos locally.

The local repos are used to generate frozen-stubs and doc-stubs.

Parameters

path (Union[str, pathlib.Path]) –

stubber.stubber.VERSION_LIST
stubber.stubber.cli_fetch(path: Union[str, pathlib.Path], tag: Optional[str] = None)

Switch to a specific version of the micropython repos.

Specify the version with –tag or –version to specify the version tag of the MicroPython repo. The Micropython-lib repo will be checked out to a commit that corresponds in time to that version tag, in order to allow non-current versions to be stubbed correctly.

The repros must be cloned already

Parameters
stubber.stubber.cli_stub(source: Union[str, pathlib.Path])

Create or update .pyi type hint files.

Parameters

source (Union[str, pathlib.Path]) –

stubber.stubber.cli_minify(ctx, source: Union[str, pathlib.Path], target: Union[str, pathlib.Path], keep_report: bool, diff: bool, cross_compile: bool, all: bool) int

Minify createstubs*.py.

Creates a minified version of the SOURCE micropython file in TARGET (file or folder). The goal is to use less memory / not to run out of memory, while generating Firmware stubs.

Parameters
Return type

int

stubber.stubber.cli_get_frozen(stub_folder: str = config.stub_path.as_posix(), version: str = '', pyi: bool = True, black: bool = True)

Get the frozen stubs for MicroPython.

Get the frozen modules for the checked out version of MicroPython

Parameters
  • stub_folder (str) –

  • version (str) –

  • pyi (bool) –

  • black (bool) –

stubber.stubber.cli_get_lobo(stub_folder: str = config.stub_path.as_posix(), pyi: bool = True, black: bool = True)

Get the frozen stubs for Lobo-esp32.

Get the frozen modules for the Loboris v3.2.24 fork of MicroPython

Parameters
  • stub_folder (str) –

  • pyi (bool) –

  • black (bool) –

stubber.stubber.cli_get_core(stub_folder: str = config.stub_path.as_posix(), pyi: bool = True, black: bool = True)

Download core CPython stubs from PyPi.

Get the core (CPython compat) modules for both MicroPython and Pycopy.

Parameters
  • stub_folder (str) –

  • pyi (bool) –

  • black (bool) –

stubber.stubber.cli_docstubs(path: str = config.repo_path.as_posix(), target: str = config.stub_path.as_posix(), verbose: bool = False, black: bool = True, basename='micropython')

Build stubs from documentation.

Read the Micropython library documentation files and use them to build stubs that can be used for static typechecking.

Parameters
stubber.stubber.cli_update_fallback(version: str, stub_folder: str = config.stub_path.as_posix())

Update the fallback stubs.

The fallback stubs are updated/collated from files of the firmware-stubs, doc-stubs and core-stubs.

Parameters
  • version (str) –

  • stub_folder (str) –