Python typing: do stubs take precedence over library sources?

Viewed 257

I'm splitting my code into multiple packages, which are installable via PyPI. Then these packages are used in a child package, where I want type information from "library" packages to be fully used. In order to have complete type checking, I'd like to use pyright / pylance, locally and in CI.

What is the recommended way to document types for a python library? I'm currently partially annotating types in the source code. Do I have to provide stubs? When using my library in other project, I get warnings like Stub file not found in vscode.

Specific questions:

  1. Is having stubs a must for a python library if I want users to have access to typing?
  2. Do stubs take precedence over source code of library if both have types?
1 Answers
Related