Installation issues
Mypy not found after installation
Ifmypy command is not found:
Version conflicts
Module and import issues
Cannot find implementation or library stub
Solution 1: Install the package
Solution 1: Install the package
The module might not be installed:
Solution 2: Install stub package
Solution 2: Install stub package
Install type stubs:
Solution 3: Ignore missing imports
Solution 3: Ignore missing imports
Add to mypy.ini:
Solution 4: Create stub file
Solution 4: Create stub file
Create a minimal stub:Then:
Module not found in MYPYPATH
Verify MYPYPATH is set correctly:Namespace package issues
For namespace packages without__init__.py:
Configuration issues
Config file not found
Mypy searches for config files in this order:mypy.ini.mypy.inipyproject.tomlsetup.cfg
Config options not working
Verify the config is being read:Per-module config not applying
Module patterns must match import names:Cache issues
Stale cache causing errors
Clear the cache:Cache permission errors
Type checking issues
False positives
Mypy reports errors that seem incorrect:- Use reveal_type
- Check for Any
- Update stubs
Debug what mypy thinks:
False negatives
Mypy doesn’t catch obvious errors:- Missing annotations: Add type hints to functions
- Any leakage: Check for implicit
Anytypes - Ignored files: Verify files are being checked
Performance issues
Slow initial run
For large codebases:Slow incremental runs
Memory issues
Daemon mode (dmypy) issues
Daemon won’t start
Check if already running:Daemon returns stale results
Restart the daemon:Socket errors
Platform-specific issues
Windows path issues
macOS compilation issues
If mypyc compilation fails:Debugging techniques
Enable verbose output
- Which files are being checked
- Which config file is being used
- Import resolution details
Show traceback for crashes
Export type information
Use reveal_type and reveal_locals
CI/CD issues
Mypy fails in CI but passes locally
Check Python version
Check Python version
Ensure CI uses same Python version:
Check mypy version
Check mypy version
Pin mypy version:
Check dependencies
Check dependencies
Install all dependencies:
Clear cache in CI
Clear cache in CI
Don’t cache mypy cache:
Common error patterns
Assignment errors
Call errors
Import errors
Getting help
If you’re still stuck:Check documentation
Review the full documentation
Search issues
Search existing GitHub issues
Ask on Gitter
Join the typing discussion
Report a bug
File a new issue