Advanced options
The following flags are useful mostly for people who are interestedin developing or debugging mypy internals.
—show-traceback
,
—tb
- If set, this flag will display a full traceback when mypyencounters a fatal error.
—custom-typing-module
MODULE
- This flag lets you use a custom module as a substitute for the
typing
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.
—warn-incomplete-stub
- This flag modifies both the
—disallow-untyped-defs
and—disallow-incomplete-defs
flags so they also report errorsif stubs in typeshed are missing type annotations or has incompleteannotations. If both flags are missing,—warn-incomplete-stub
also does nothing.
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 ofSHADOW_FILE
instead. However,diagnostics will continue to refer toSOURCE_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
.