| 1 | usage: mypy [-h] [-v] [-V] [more options; see below]
|
| 2 | [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
|
| 3 |
|
| 4 | Mypy is a program that will type check your Python code.
|
| 5 |
|
| 6 | Pass in any files or folders you want to type check. Mypy will
|
| 7 | recursively traverse any provided folders to find .py files:
|
| 8 |
|
| 9 | $ mypy my_program.py my_src_folder
|
| 10 |
|
| 11 | For more information on getting started, see:
|
| 12 |
|
| 13 | - http://mypy.readthedocs.io/en/latest/getting_started.html
|
| 14 |
|
| 15 | For more details on both running mypy and using the flags below, see:
|
| 16 |
|
| 17 | - http://mypy.readthedocs.io/en/latest/running_mypy.html
|
| 18 | - http://mypy.readthedocs.io/en/latest/command_line.html
|
| 19 |
|
| 20 | You can also use a config file to configure mypy instead of using
|
| 21 | command line flags. For more details, see:
|
| 22 |
|
| 23 | - http://mypy.readthedocs.io/en/latest/config_file.html
|
| 24 |
|
| 25 | Optional arguments:
|
| 26 | -h, --help Show this help message and exit
|
| 27 | -v, --verbose More verbose messages
|
| 28 | -V, --version Show program's version number and exit
|
| 29 |
|
| 30 | Config file:
|
| 31 | Use a config file instead of command line arguments. This is useful if you
|
| 32 | are using many flags or want to set different options per each module.
|
| 33 |
|
| 34 | --config-file CONFIG_FILE
|
| 35 | Configuration file, must have a [mypy] section
|
| 36 | (defaults to mypy.ini, setup.cfg, ~/.mypy.ini)
|
| 37 | --warn-unused-configs Warn about unused '[mypy-<pattern>]' config
|
| 38 | sections (inverse: --no-warn-unused-configs)
|
| 39 |
|
| 40 | Import discovery:
|
| 41 | Configure how imports are discovered and followed.
|
| 42 |
|
| 43 | --ignore-missing-imports Silently ignore imports of missing modules
|
| 44 | --follow-imports {normal,silent,skip,error}
|
| 45 | How to treat imports (default normal)
|
| 46 | --python-executable EXECUTABLE
|
| 47 | Python executable used for finding PEP 561
|
| 48 | compliant installed packages and stubs
|
| 49 | --no-site-packages Do not search for installed PEP 561 compliant
|
| 50 | packages
|
| 51 | --no-silence-site-packages
|
| 52 | Do not silence errors in PEP 561 compliant
|
| 53 | installed packages
|
| 54 | --namespace-packages Support namespace packages (PEP 420, __init__.py-
|
| 55 | less) (inverse: --no-namespace-packages)
|
| 56 |
|
| 57 | Platform configuration:
|
| 58 | Type check code assuming it will be run under certain runtime conditions.
|
| 59 | By default, mypy assumes your code will be run using the same operating
|
| 60 | system and Python version you are using to run mypy itself.
|
| 61 |
|
| 62 | --python-version x.y Type check code assuming it will be running on
|
| 63 | Python x.y
|
| 64 | -2, --py2 Use Python 2 mode (same as --python-version 2.7)
|
| 65 | --platform PLATFORM Type check special-cased code for the given OS
|
| 66 | platform (defaults to sys.platform)
|
| 67 | --always-true NAME Additional variable to be considered True (may be
|
| 68 | repeated)
|
| 69 | --always-false NAME Additional variable to be considered False (may be
|
| 70 | repeated)
|
| 71 |
|
| 72 | Dynamic typing:
|
| 73 | Disallow the use of the dynamic 'Any' type under certain conditions.
|
| 74 |
|
| 75 | --disallow-any-unimported
|
| 76 | Disallow Any types resulting from unfollowed
|
| 77 | imports
|
| 78 | --disallow-subclassing-any
|
| 79 | Disallow subclassing values of type 'Any' when
|
| 80 | defining classes (inverse: --allow-subclassing-
|
| 81 | any)
|
| 82 | --disallow-any-expr Disallow all expressions that have type Any
|
| 83 | --disallow-any-decorated Disallow functions that have Any in their
|
| 84 | signature after decorator transformation
|
| 85 | --disallow-any-explicit Disallow explicit Any in type positions
|
| 86 | --disallow-any-generics Disallow usage of generic types that do not
|
| 87 | specify explicit type parameters (inverse:
|
| 88 | --allow-any-generics)
|
| 89 |
|
| 90 | Untyped definitions and calls:
|
| 91 | Configure how untyped definitions and calls are handled. Note: by default,
|
| 92 | mypy ignores any untyped function definitions and assumes any calls to
|
| 93 | such functions have a return type of 'Any'.
|
| 94 |
|
| 95 | --disallow-untyped-calls Disallow calling functions without type
|
| 96 | annotations from functions with type annotations
|
| 97 | (inverse: --allow-untyped-calls)
|
| 98 | --disallow-untyped-defs Disallow defining functions without type
|
| 99 | annotations or with incomplete type annotations
|
| 100 | (inverse: --allow-untyped-defs)
|
| 101 | --disallow-incomplete-defs
|
| 102 | Disallow defining functions with incomplete type
|
| 103 | annotations (inverse: --allow-incomplete-defs)
|
| 104 | --check-untyped-defs Type check the interior of functions without type
|
| 105 | annotations (inverse: --no-check-untyped-defs)
|
| 106 | --disallow-untyped-decorators
|
| 107 | Disallow decorating typed functions with untyped
|
| 108 | decorators (inverse: --allow-untyped-decorators)
|
| 109 |
|
| 110 | None and Optional handling:
|
| 111 | Adjust how values of type 'None' are handled. For more context on how mypy
|
| 112 | handles values of type 'None', see:
|
| 113 | mypy.readthedocs.io/en/latest/kinds_of_types.html#no-strict-optional
|
| 114 |
|
| 115 | --no-implicit-optional Don't assume arguments with default values of None
|
| 116 | are Optional (inverse: --implicit-optional)
|
| 117 | --no-strict-optional Disable strict Optional checks (inverse: --strict-
|
| 118 | optional)
|
| 119 | --strict-optional-whitelist [GLOB [GLOB ...]]
|
| 120 | Suppress strict Optional errors in all but the
|
| 121 | provided files; implies --strict-optional (may
|
| 122 | suppress certain other errors in non-whitelisted
|
| 123 | files)
|
| 124 |
|
| 125 | Warnings:
|
| 126 | Detect code that is sound but redundant or problematic.
|
| 127 |
|
| 128 | --warn-redundant-casts Warn about casting an expression to its inferred
|
| 129 | type (inverse: --no-warn-redundant-casts)
|
| 130 | --warn-unused-ignores Warn about unneeded '# type: ignore' comments
|
| 131 | (inverse: --no-warn-unused-ignores)
|
| 132 | --no-warn-no-return Do not warn about functions that end without
|
| 133 | returning (inverse: --warn-no-return)
|
| 134 | --warn-return-any Warn about returning values of type Any from non-
|
| 135 | Any typed functions (inverse: --no-warn-return-
|
| 136 | any)
|
| 137 |
|
| 138 | Other strictness checks:
|
| 139 | --allow-untyped-globals Suppress toplevel errors caused by missing
|
| 140 | annotations (inverse: --disallow-untyped-globals)
|
| 141 | --strict Strict mode; enables the following flags: --warn-
|
| 142 | unused-configs, --disallow-subclassing-any,
|
| 143 | --disallow-any-generics, --disallow-untyped-calls,
|
| 144 | --disallow-untyped-defs, --disallow-incomplete-
|
| 145 | defs, --check-untyped-defs, --disallow-untyped-
|
| 146 | decorators, --no-implicit-optional, --warn-
|
| 147 | redundant-casts, --warn-unused-ignores, --warn-
|
| 148 | return-any
|
| 149 |
|
| 150 | Incremental mode:
|
| 151 | Adjust how mypy incrementally type checks and caches modules. Mypy caches
|
| 152 | type information about modules into a cache to let you speed up future
|
| 153 | invocations of mypy. Also see mypy's daemon mode:
|
| 154 | mypy.readthedocs.io/en/latest/mypy_daemon.html#mypy-daemon
|
| 155 |
|
| 156 | --no-incremental Disable module cache (inverse: --incremental)
|
| 157 | --cache-dir DIR Store module cache info in the given folder in
|
| 158 | incremental mode (defaults to '.mypy_cache')
|
| 159 | --sqlite-cache Use a sqlite database to store the cache (inverse:
|
| 160 | --no-sqlite-cache)
|
| 161 | --cache-fine-grained Include fine-grained dependency information in the
|
| 162 | cache for the mypy daemon
|
| 163 | --skip-version-check Allow using cache written by older mypy version
|
| 164 |
|
| 165 | Mypy internals:
|
| 166 | Debug and customize mypy internals.
|
| 167 |
|
| 168 | --pdb Invoke pdb on fatal error
|
| 169 | --show-traceback, --tb Show traceback on fatal error
|
| 170 | --raise-exceptions Raise exception on fatal error
|
| 171 | --custom-typing MODULE Use a custom typing module
|
| 172 | --custom-typeshed-dir DIR
|
| 173 | Use the custom typeshed in DIR
|
| 174 | --warn-incomplete-stub Warn if missing type annotation in typeshed, only
|
| 175 | relevant with --disallow-untyped-defs or
|
| 176 | --disallow-incomplete-defs enabled (inverse: --no-
|
| 177 | warn-incomplete-stub)
|
| 178 | --shadow-file SOURCE_FILE SHADOW_FILE
|
| 179 | When encountering SOURCE_FILE, read and type check
|
| 180 | the contents of SHADOW_FILE instead.
|
| 181 |
|
| 182 | Error reporting:
|
| 183 | Adjust the amount of detail shown in error messages.
|
| 184 |
|
| 185 | --show-error-context Precede errors with "note:" messages explaining
|
| 186 | context (inverse: --hide-error-context)
|
| 187 | --show-column-numbers Show column numbers in error messages (inverse:
|
| 188 | --hide-column-numbers)
|
| 189 |
|
| 190 | Report generation:
|
| 191 | Generate a report in the specified format.
|
| 192 |
|
| 193 | --any-exprs-report DIR
|
| 194 | --cobertura-xml-report DIR
|
| 195 | --html-report DIR
|
| 196 | --linecount-report DIR
|
| 197 | --linecoverage-report DIR
|
| 198 | --memory-xml-report DIR
|
| 199 | --txt-report DIR
|
| 200 | --xml-report DIR
|
| 201 | --xslt-html-report DIR
|
| 202 | --xslt-txt-report DIR
|
| 203 |
|
| 204 | Miscellaneous:
|
| 205 | --junit-xml JUNIT_XML Write junit.xml to the given file
|
| 206 | --scripts-are-modules Script x becomes module x instead of __main__
|
| 207 | --find-occurrences CLASS.MEMBER
|
| 208 | Print out all usages of a class member
|
| 209 | (experimental)
|
| 210 |
|
| 211 | Running code:
|
| 212 | Specify the code you want to type check. For more details, see
|
| 213 | mypy.readthedocs.io/en/latest/running_mypy.html#running-mypy
|
| 214 |
|
| 215 | -m MODULE, --module MODULE
|
| 216 | Type-check module; can repeat for more modules
|
| 217 | -p PACKAGE, --package PACKAGE
|
| 218 | Type-check package recursively; can be repeated
|
| 219 | -c PROGRAM_TEXT, --command PROGRAM_TEXT
|
| 220 | Type-check program passed in as string
|
| 221 | files Type-check given files or directories
|
| 222 |
|
| 223 | Environment variables:
|
| 224 | Define MYPYPATH for additional module search path entries.
|