reportMissingTypeStubs is a diagnostic in Pylance and Pyright that warns when a module is missing type stubs (.pyi files) or type annotations. This helps catch missing type information for third-party libraries, improving static analysis and type safety.
- #9393: Ensure that all modules within the 'google.cloud' namespace include a 'py.typed' marker and appropriate type annotations to avoid errors like 'reportMissingTypeStubs'.
import some_library # Warning: Stub file not found for "some_library"Fix — install type stubs if available:
pip install types-some_library
# or for common packages:
pip install types-requests types-PyYAMLFix — use useLibraryCodeForTypes to infer types from source:
// .vscode/settings.json
{
"python.analysis.useLibraryCodeForTypes": true
}- Install or generate type stubs (
.pyifiles) for third-party libraries. - Use libraries that provide type annotations or a
py.typedmarker file. - Contribute type stubs to the typeshed repository or the library itself if missing.
- Review the Pyright configuration documentation for options to adjust or suppress this diagnostic if needed.
Stub-only packages (like boto3-stubs, types-requests) must match the version of the library they describe. If you install types-requests==2.28.0 but have requests==2.31.0, the stubs may define different APIs, causing false errors.
Fix: keep stub-package versions aligned with library versions:
pip install requests==2.31.0 types-requests==2.31.0For AWS SDK stubs (boto3-stubs, mypy-boto3-*), install matching versions and the service-specific sub-packages:
pip install 'boto3-stubs[s3,ec2]' # installs service stubs for s3 and ec2Diagnosis: run pip list | grep types- (or pip list | grep stubs) and compare versions against the library they describe.
If a stub package produces errors itself (e.g., internal stub inconsistencies), check for newer versions or file an issue on the stub package's repository.
python.analysis.useLibraryCodeForTypes— use library source when type stubs are missingpython.analysis.stubPath— specify a custom path for type stubspython.analysis.diagnosticSeverityOverrides— adjust or suppress this diagnosticpython.analysis.typeCheckingMode— controls which diagnostics are enabled by default