dmypy
Run Mypy type checks via daemon
TLDR
Type check a file, and start the daemon if it is not running
Start the daemon
Type check a file (requires the daemon to be running)
Stop the daemon
SYNOPSIS
dmypy [-h] [-V] [--config-file FILE] [--log-dir DIR] [--status-file FILE] [--wait]
{start|run|status|stop|restart|kill} [<args>]
PARAMETERS
-h, --help
Show help message and exit.
-V, --version
Show program's version number and exit.
--config-file FILE
Path to mypy configuration file (mypy.ini or pyproject.toml).
--log-dir DIR
Directory for daemon log files.
--status-file FILE
File to store daemon status (PID, socket).
--wait
Wait for daemon startup before exiting.
start [-- <daemon-options>]
Start the mypy daemon server; daemon-options passed after --.
run [-- <run-options>] <files>...
Run incremental type check on files using daemon; options after --.
status
Print daemon status (running/PID/socket).
stop
Gracefully stop the daemon.
restart
Stop and immediately restart the daemon.
kill
Force-kill the daemon process.
DESCRIPTION
dmypy is the daemonized version of mypy, a static type checker for Python code. It runs a persistent server that maintains an in-memory cache of type information, enabling significantly faster incremental type checks compared to standard mypy invocations. This is ideal for large codebases, IDE integrations, or repeated checks in development workflows.
The workflow starts with dmypy start to launch the server, optionally passing mypy daemon options after --. Use dmypy run followed by files or directories to check incrementally. Other commands manage the daemon: status shows server state, stop shuts it down, restart restarts it, and kill forcefully terminates.
dmypy supports mypy configuration files and most flags, inheriting options like --strict or --python-version. It improves performance by avoiding full re-parsing and type inference on unchanged files, but requires compatible Python versions (3.7+ typically). Logs and status files aid debugging in shared or CI environments.
CAVEATS
Daemon persists across sessions, consuming memory (~100-500MB for large projects); use stop or kill to clean up. Not compatible with all mypy plugins. Requires mypy installation. Socket files may need cleanup if crashed.
EXAMPLE USAGE
dmypy start -- --strict
dmypy run src/*.py
dmypy status
dmypy stop
CONFIGURATION
Uses standard mypy config (mypy.ini or pyproject.toml). Daemon inherits settings; override with --config-file or command-line.
HISTORY
Introduced in mypy 0.401 (January 2017) to address performance issues in incremental checking. Developed by mypy team led by Jukka Lehtosalo; evolved with mypy releases, now at feature parity with mypy 1.x. Widely used in IDEs like VS Code via pylsp-mypy.
SEE ALSO
mypy(1), stubgen(1)


