Skip to content
Latchkey

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.

mypy output
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.

Terminal
mypy --install-types --non-interactive .
# or pin them
pip install types-requests types-PyYAML

Fix real type errors

  1. Read each error’s file:line and the [error-code] in brackets.
  2. Correct the actual type mismatch in the code.
  3. For untyped third-party imports with no stubs, scope ignore_missing_imports to 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_imports to specific modules.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →