DOKK / manpages / debian 10 / mypy / mypy.1.en
MYPY(1) User Commands MYPY(1)

mypy - Optional Static Typing for Python

usage: mypy [-h] [-v] [-V] [more options; see below]

[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]

Mypy is a program that will type check your Python code.

Pass in any files or folders you want to type check. Mypy will recursively traverse any provided folders to find .py files:

$ mypy my_program.py my_src_folder

For more information on getting started, see:

- http://mypy.readthedocs.io/en/latest/getting_started.html

For more details on both running mypy and using the flags below, see:

- http://mypy.readthedocs.io/en/latest/running_mypy.html - http://mypy.readthedocs.io/en/latest/command_line.html

You can also use a config file to configure mypy instead of using command line flags. For more details, see:

- http://mypy.readthedocs.io/en/latest/config_file.html

Show this help message and exit
More verbose messages
Show program's version number and exit

Use a config file instead of command line arguments. This is useful if you are using many flags or want to set different options per each module.
Configuration file, must have a [mypy] section (defaults to mypy.ini, setup.cfg, ~/.config/mypy/config, ~/.mypy.ini)
Warn about unused '[mypy-<pattern>]' config sections (inverse: --no-warn-unused-configs)

Configure how imports are discovered and followed.
Silently ignore imports of missing modules
How to treat imports (default normal)
Python executable used for finding PEP 561 compliant installed packages and stubs
Do not search for installed PEP 561 compliant packages
Do not silence errors in PEP 561 compliant installed packages
Support namespace packages (PEP 420, __init__.pyless) (inverse: --no-namespace-packages)

Type check code assuming it will be run under certain runtime conditions. By default, mypy assumes your code will be run using the same operating system and Python version you are using to run mypy itself.
Type check code assuming it will be running on Python x.y
-2, --py2
Use Python 2 mode (same as --python-version 2.7)
Type check special-cased code for the given OS platform (defaults to sys.platform)
Additional variable to be considered True (may be repeated)
Additional variable to be considered False (may be repeated)

Disallow the use of the dynamic 'Any' type under certain conditions.
Disallow Any types resulting from unfollowed imports
Disallow subclassing values of type 'Any' when defining classes (inverse: --allow-subclassingany)
Disallow all expressions that have type Any
Disallow functions that have Any in their signature after decorator transformation
Disallow explicit Any in type positions
Disallow usage of generic types that do not specify explicit type parameters (inverse: --allow-any-generics)

Configure how untyped definitions and calls are handled. Note: by default, mypy ignores any untyped function definitions and assumes any calls to such functions have a return type of 'Any'.
Disallow calling functions without type annotations from functions with type annotations (inverse: --allow-untyped-calls)
Disallow defining functions without type annotations or with incomplete type annotations (inverse: --allow-untyped-defs)
Disallow defining functions with incomplete type annotations (inverse: --allow-incomplete-defs)
Type check the interior of functions without type annotations (inverse: --no-check-untyped-defs)
Disallow decorating typed functions with untyped decorators (inverse: --allow-untyped-decorators)

Adjust how values of type 'None' are handled. For more context on how mypy handles values of type 'None', see: mypy.readthedocs.io/en/latest/kinds_of_types.html#no-strict-optional
Don't assume arguments with default values of None are Optional (inverse: --implicit-optional)
Disable strict Optional checks (inverse: --strictoptional)
Suppress strict Optional errors in all but the provided files; implies --strict-optional (may suppress certain other errors in non-whitelisted files)

Detect code that is sound but redundant or problematic.
Warn about casting an expression to its inferred type (inverse: --no-warn-redundant-casts)
Warn about unneeded '# type: ignore' comments (inverse: --no-warn-unused-ignores)
Do not warn about functions that end without returning (inverse: --warn-no-return)
Warn about returning values of type Any from nonAny typed functions (inverse: --no-warn-returnany)

Suppress toplevel errors caused by missing annotations (inverse: --disallow-untyped-globals)
Allow unconditional variable redefinition with a new type (inverse: --disallow-redefinition)
Strict mode; enables the following flags: --warnunused-configs, --disallow-subclassing-any, --disallow-any-generics, --disallow-untyped-calls, --disallow-untyped-defs, --disallow-incompletedefs, --check-untyped-defs, --disallow-untypeddecorators, --no-implicit-optional, --warnredundant-casts, --warn-unused-ignores, --warnreturn-any

Adjust how mypy incrementally type checks and caches modules. Mypy caches type information about modules into a cache to let you speed up future invocations of mypy. Also see mypy's daemon mode: mypy.readthedocs.io/en/latest/mypy_daemon.html#mypy-daemon
Disable module cache (inverse: --incremental)
Store module cache info in the given folder in incremental mode (defaults to '.mypy_cache')
Use a sqlite database to store the cache (inverse: --no-sqlite-cache)
Include fine-grained dependency information in the cache for the mypy daemon
Allow using cache written by older mypy version

Debug and customize mypy internals.
Invoke pdb on fatal error
Show traceback on fatal error
Raise exception on fatal error
Use a custom typing module
Use the custom typeshed in DIR
Warn if missing type annotation in typeshed, only relevant with --disallow-untyped-defs or --disallow-incomplete-defs enabled (inverse: --nowarn-incomplete-stub)
When encountering SOURCE_FILE, read and type check the contents of SHADOW_FILE instead.

Adjust the amount of detail shown in error messages.
Precede errors with "note:" messages explaining context (inverse: --hide-error-context)
Show column numbers in error messages (inverse: --hide-column-numbers)

Generate a report in the specified format.

--any-exprs-report DIR

--cobertura-xml-report DIR

--html-report DIR

--linecount-report DIR

--linecoverage-report DIR

--memory-xml-report DIR

--txt-report DIR

--xml-report DIR

--xslt-html-report DIR

--xslt-txt-report DIR

Write junit.xml to the given file
Script x becomes module x instead of __main__
Print out all usages of a class member (experimental)

Specify the code you want to type check. For more details, see mypy.readthedocs.io/en/latest/running_mypy.html#running-mypy
Type-check module; can repeat for more modules
Type-check package recursively; can be repeated
Type-check program passed in as string
Type-check given files or directories

Define MYPYPATH for additional module search path entries.
February 2019 mypy 0.670