stubpy

stubpy generates .pyi stub files for Python modules — complete with full **kwargs / *args MRO backtracing, type-alias preservation, Generic and overload support, and cross-file import resolution.

pip install stubpy
stubpy mymodule.py          # → mymodule.pyi
stubpy mypackage/           # → stubs entire package tree

Why stubpy?

Most stub generators leave **kwargs as **kwargs. stubpy walks the entire class MRO to expand **kwargs into the concrete named parameters that the method actually accepts — giving IDEs full auto-complete even across deep inheritance hierarchies.

At a glance

**kwargs backtracing

Walks MRO to emit every concrete kwarg, including pos-only promotion

Function-level forwarding

Module-level functions that forward **kwargs are also expanded

TypeVar / Generic / overload

TypeVar, TypeAlias, NewType, Generic[T], @overload all preserved

TypedDict / Enum / dataclass

Dedicated clean stubs for every special class form

Type-alias preservation

types.Length stays types.Length, not str | float | int

Cross-file imports

Base-class and annotation imports auto-added to the .pyi header

Package batch generation

One call stubs an entire directory tree

Custom annotation handlers

Extend the dispatch table with register_annotation_handler()

Zero runtime dependencies

stdlib only