Skip to main content
The dmypy command is a client for controlling the mypy daemon (server). Running mypy as a daemon can be 10x or more faster than the regular command-line tool for large codebases, especially for incremental checks.

How it works

The daemon keeps program state cached in memory and uses fine-grained dependency tracking to minimize reprocessing. This makes subsequent type checking runs much faster after the initial run.
Each mypy daemon process supports one user and one set of source files, and can only process one type checking request at a time.

Basic usage

# Start daemon and check files (recommended)
dmypy run -- prog.py pkg/*.py

# The daemon automatically restarts if configuration or mypy version changes
dmypy run -- --strict mycode.py

Daemon lifecycle commands

run
command
Check files, starting or restarting the daemon if needed. This is the recommended command for most workflows.
dmypy run -- <mypy-flags> <files>
start
command
Start the daemon but do not check any files.
dmypy start -- <mypy-flags>
restart
command
Restart the daemon. Equivalent to stop followed by start.
dmypy restart -- <mypy-flags>
stop
command
Stop the daemon.
dmypy stop
kill
command
Kill the daemon process.
dmypy kill
status
command
Check whether a daemon is running.
dmypy status
dmypy status -v  # Verbose output

Type checking commands

check
command
Check a list of files using an already running daemon.
dmypy check file1.py file2.py
dmypy check --export-types src/
recheck
command
Re-check the same set of files as the most recent check or recheck command.
dmypy recheck
dmypy recheck --update file.py  # Add or re-check specific file
dmypy recheck --remove file.py  # Remove file from check set

Inspection commands

suggest
command
Suggest a signature or show call sites for a specific function.
dmypy suggest module.function
dmypy suggest /path/to/file.py:42
dmypy suggest --json module.function
inspect
command
Locate and statically inspect expression(s).
dmypy inspect path/to/file.py:line:column
dmypy inspect --show attrs file.py:10:5
dmypy inspect --show definition file.py:10:5

Common flags

--status-file FILE
string
Use FILE as the status file for storing daemon runtime state.Default: .dmypy.json in current directory
--timeout TIMEOUT
number
Server shutdown timeout in seconds. Automatically shut down after TIMEOUT seconds of inactivity.Available for: start, restart, run commands
--log-file FILE
string
Direct daemon stdout/stderr to FILE. Useful for debugging daemon crashes.Available for: start, restart, run commands
-V, --version
boolean
Show program’s version number and exit.

Check and recheck flags

-v, --verbose
boolean
Print detailed status.
--junit-xml FILE
string
Write junit.xml to the given file.
--perf-stats-file FILE
string
Write performance information to the given file.
--export-types
boolean
Store types of all expressions in a shared location (useful for inspections).Default: false
--update FILE
string
Re-check FILE, or add it to the set of files being checked. May be repeated.Only available for recheck command.
--remove FILE
string
Remove FILE from the set of files being checked. May be repeated.Only available for recheck command.

Status command flags

--fswatcher-dump-file FILE
string
Collect information about the current file state and write to FILE as JSON.

Suggest command flags

--json
boolean
Produce json that pyannotate can use to apply a suggestion.Default: false
--no-errors
boolean
Only produce suggestions that cause no errors.Default: false
--no-any
boolean
Only produce suggestions that don’t contain Any.Default: false
--flex-any SCORE
number
Allow anys in types if they go above a certain score (0-1).
--callsites
boolean
Find callsites instead of suggesting a type.Default: false
--use-fixme NAME
string
A dummy name to use instead of Any for types that can’t be inferred.
--max-guesses NUM
number
Set the maximum number of types to try for a function.Default: 64

Inspect command flags

--show INSPECTION
string
What kind of inspection to run.Choices: type, attrs, definitionDefault: type
-v, --verbose
boolean
Increase verbosity of the type string representation. Can be repeated.
--limit NUM
number
Return at most NUM innermost expressions (if position is given). 0 means no limit.Default: 0
--include-span
boolean
Prepend each inspection result with the span of corresponding expression.Default: false
--include-kind
boolean
Prepend each inspection result with the kind of corresponding expression.Default: false
--include-object-attrs
boolean
Include attributes of “object” in “attrs” inspection.Default: false
--union-attrs
boolean
Include attributes valid for some of possible expression types.Default: false (intersection returned)
--force-reload
boolean
Re-parse and re-type-check file before inspection (may be slow).Default: false

Examples

# Recommended: use 'run' to automatically start daemon
dmypy run -- --strict mycode.py

# Output
Daemon started
Success: no issues found in 1 source file
For best performance with dmypy inspect, always use --export-types when checking files. This pre-computes type information for faster lookups.
The daemon requires --local-partial-types and automatically enables it. This may affect type inference behavior compared to regular mypy.

Performance tips

  1. Use dmypy run: This automatically handles daemon lifecycle and restarts when needed
  2. Enable --export-types: Pre-compute types for faster inspections
  3. Use --update/--remove: With an external file watcher for maximum speed on large codebases
  4. Set --timeout: Automatically clean up idle daemon processes

Build docs developers (and LLMs) love