mypy "Found N errors in M files" Failing CI - Type-Check Failures
mypy exited non-zero because it found type errors. Some are genuine type mismatches in your code; a common CI-only class is "missing library stubs" - mypy cannot find type information for a dependency.
What this error means
A mypy step fails with Found N errors in M files and exit code 1. Errors range from real incompatible type issues to error: Library stubs not installed for "X" or Cannot find implementation or library stub.
app/client.py:14: error: Library stubs not installed for "requests" [import-untyped]
app/util.py:8: error: Argument 1 to "len" has incompatible type "int"; expected "Sized" [arg-type]
Found 2 errors in 2 files (checked 12 source files)Common causes
Genuine type errors
Code has real type mismatches mypy is correctly flagging. These should be fixed, not suppressed.
Missing third-party stubs
A dependency ships no inline types and its stub package is not installed, so mypy reports import-untyped/Cannot find ... library stub in CI.
How to fix it
Install missing stubs
Let mypy install the stub packages it needs, or add them to dev deps.
mypy --install-types --non-interactive .
# or pin them
pip install types-requests types-PyYAMLFix real type errors
- Read each error’s file:line and the
[error-code]in brackets. - Correct the actual type mismatch in the code.
- For untyped third-party imports with no stubs, scope
ignore_missing_importsto that module, not globally.
How to prevent it
- Add stub packages (
types-*) to dev dependencies. - Run mypy locally/in pre-commit so errors surface before CI.
- Scope any
ignore_missing_importsto specific modules.