API Reference

Every public name of the stubpy package and of stubpy.extend. Names starting with an underscore and the modules behind them are internal and may change without notice.

Functions

See Functions.

render()

Build the stub of one module and return it, writing nothing.

generate()

Write stubs for files, folders, packages or modules.

check()

Compare the stubs on disk with what would be generated.

load_config()

Read [tool.stubpy] or stubpy.toml into a Config.

sync_docstrings()

Copy runtime docstrings into a hand-written stub of a compiled module.

Configuration

See Configuration.

Config

Frozen dataclass holding every option of a run.

DocstringTargets

Field type of Config.docstrings: the stubs stubpy docstrings acts on.

ImportPolicy

Which modules may be imported: Config.imports and Config.deny_imports.

UnionStyle

Field type of Config.union_style: modern or legacy.

AliasStyle

Field type of Config.alias_style: compatible, pep695 or auto.

Results

See Results and diagnostics.

StubResult

Stub text and diagnostics of one module.

Report

Outcome of a generate or check run over many modules.

Diagnostic

One message recorded while building a stub.

Level

Severity of a diagnostic: INFO, WARNING or ERROR.

Hints

See Hints.

stubpy.hint.signature()

Decorator that sets the stub signature of a callable.

stubpy.hint.returns()

Decorator that sets only the return type.

stubpy.hint.ignore()

Decorator that leaves a symbol out of the stub.

Extension namespace

See stubpy.extend.

stubpy.extend.register_annotation_handler()

Render your own annotation types.

stubpy.extend.annotation_to_str()

Convert an annotation to stub text.

stubpy.extend.ast_harvest()

Parse source into ASTSymbols.

stubpy.extend.build_symbol_table()

Merge live and parsed data into a SymbolTable.

SymbolTable

Every symbol of a module, by name and kind.

ASTSymbols

What the parser found in a source file.

ClassSymbol, FunctionSymbol, VariableSymbol, AliasSymbol, OverloadGroup

Symbol entries of the table.

SymbolKind

Kind of a symbol.

StubContext

State shared by one run.

AliasEntry

A registered type alias.

DiagnosticCollector

Collects the diagnostics of a run.

Stage

Pipeline stage that raised a diagnostic.

stubpy.__version__ holds the installed version string.