stubpy

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

Key features

  • kwargs backtracing — walks the entire MRO to expand **kwargs into concrete, named parameters at every inheritance level.

  • cls() detection@classmethod methods that forward **kwargs into cls(...) are resolved against cls.__init__, not the MRO.

  • Typed *args preserved — explicitly annotated *args (e.g. *elements: Element) always survive the resolution chain.

  • Type-alias preservationtypes.Length stays types.Length rather than expanding to str | float | int.

  • Cross-file imports — base classes and annotation types from other local modules are re-emitted in the .pyi header automatically.

  • Zero dependencies — stdlib only at runtime.


Project