Advanced options

The following flags are useful mostly for people who are interestedin developing or debugging mypy internals.

  • —pdb
  • This flag will invoke the Python debugger when mypy encountersa fatal error.
  • —show-traceback, —tb
  • If set, this flag will display a full traceback when mypyencounters a fatal error.
  • —raise-exceptions
  • Raise exception on fatal error.
  • —custom-typing-module MODULE
  • This flag lets you use a custom module as a substitute for thetyping module.
  • —custom-typeshed-dir DIR
  • This flag specifies the directory where mypy looks for typeshedstubs, instead of the typeshed that ships with mypy. This isprimarily intended to make it easier to test typeshed changes beforesubmitting them upstream, but also allows you to use a forked version oftypeshed.

This flag is mainly intended to be used by people who want contributeto typeshed and would like a convenient way to find gaps and omissions.

If you want mypy to report an error when your codebase uses an untypedfunction, whether that function is defined in typeshed or not, use the—disallow-untyped-calls flag. See Untyped definitions and callsfor more details.

  • —shadow-file SOURCE_FILE SHADOW_FILE
  • When mypy is asked to type check SOURCE_FILE, this flag makes mypyread from and type check the contents of SHADOW_FILE instead. However,diagnostics will continue to refer to SOURCE_FILE.

Specifying this argument multiple times (—shadow-file X1 Y1 —shadow-file X2 Y2)will allow mypy to perform multiple substitutions.

This allows tooling to create temporary files with helpful modificationswithout having to change the source file in place. For example, suppose wehave a pipeline that adds reveal_type for certain variables.This pipeline is run on original.py to produce temp.py.Running mypy —shadow-file original.py temp.py original.py will thencause mypy to type check the contents of temp.py instead of original.py,but error messages will still reference original.py.