mypy "Cannot find implementation or library stub" in CI
mypy could not find type information for an imported module - no inline types, no bundled py.typed, and no installed stub package. It reports the module as unresolved for typing and fails the run.
What this error means
mypy fails with error: Cannot find implementation or library stub for module named "X" (or [import-untyped]/[import-not-found]), often suggesting a types-X stub package to install.
app/client.py:3: error: Cannot find implementation or library stub for
module named "requests" [import-untyped]
app/client.py:3: note: Hint: "python3 -m pip install types-requests"Common causes
The library ships no types and no stub is installed
The package has no inline annotations or py.typed, and the corresponding types-* stub package is not installed, so mypy has nothing to check against.
A first-party module not on mypy’s path
For your own modules, import-not-found means the package is not installed/discoverable, so mypy cannot locate the implementation.
How to fix it
Install the stub package
Add the types-* stub mypy suggests (or let mypy install them).
pip install types-requests
# or let mypy fetch missing stubs
mypy --install-types --non-interactive .Configure handling for genuinely untyped deps
For a dependency with no stubs, ignore missing imports for that module rather than globally.
[[tool.mypy.overrides]]
module = ["some_untyped_lib.*"]
ignore_missing_imports = trueHow to prevent it
- Install needed
types-*stub packages in the typecheck environment. - Scope
ignore_missing_importsto specific untyped modules, not globally. - Install your own project so first-party modules resolve for mypy.