1MYPY(1) User Commands MYPY(1)
2
3
4
6 mypy - manual page for mypy 0.620-dev
7
9 usage: mypy [-h] [-v] [-V] [--config-file CONFIG_FILE]
10 [--warn-unused-configs]
11
12 [--ignore-missing-imports] [--follow-imports {nor‐
13 mal,silent,skip,error}] [--python-executable EXECUTABLE]
14 [--no-site-packages] [--no-silence-site-packages] [--python-ver‐
15 sion x.y] [-2] [--platform PLATFORM] [--always-true NAME]
16 [--always-false NAME] [--disallow-any-unimported] [--disal‐
17 low-subclassing-any] [--disallow-any-expr] [--disallow-any-deco‐
18 rated] [--disallow-any-explicit] [--disallow-any-generics]
19 [--disallow-untyped-calls] [--disallow-untyped-defs] [--disal‐
20 low-incomplete-defs] [--check-untyped-defs] [--warn-incom‐
21 plete-stub] [--no-implicit-optional] [--no-strict-optional]
22 [--strict-optional-whitelist [GLOB [GLOB ...]]] [--warn-redun‐
23 dant-casts] [--no-warn-no-return] [--warn-return-any]
24 [--warn-unused-ignores] [--disallow-untyped-decorators]
25 [--no-incremental] [--cache-dir DIR] [--cache-fine-grained]
26 [--quick-and-dirty] [--skip-version-check] [--pdb]
27 [--show-traceback] [--custom-typing MODULE] [--custom-type‐
28 shed-dir DIR] [--shadow-file SOURCE_FILE SHADOW_FILE]
29 [--show-error-context] [--show-column-numbers] [--find-occur‐
30 rences CLASS.MEMBER] [--strict] [--any-exprs-report DIR]
31 [--cobertura-xml-report DIR] [--html-report DIR]
32 [--linecount-report DIR] [--linecoverage-report DIR] [--mem‐
33 ory-xml-report DIR] [--txt-report DIR] [--xml-report DIR]
34 [--xslt-html-report DIR] [--xslt-txt-report DIR] [--junit-xml
35 JUNIT_XML] [--scripts-are-modules] [-m MODULE] [-p PACKAGE] [-c
36 PROGRAM_TEXT] [files [files ...]]
37
38 optional arguments:
39 -h, --help
40 show this help message and exit
41
42 -v, --verbose
43 more verbose messages
44
45 -V, --version
46 show program's version number and exit
47
48 config file:
49 Use a config file instead of command line arguments.
50
51 --config-file CONFIG_FILE
52 configuration file, must have a [mypy] section (defaults to
53 mypy.ini, setup.cfg, ~/.mypy.ini)
54
55 --warn-unused-configs
56 warn about unused '[mypy-<pattern>]' config sections (inverse:
57 --no-warn-unused-configs)
58
59 import discovery:
60 Configure how imports are discovered and followed.
61
62 --ignore-missing-imports
63 silently ignore imports of missing modules
64
65 --follow-imports {normal,silent,skip,error}
66 how to treat imports (default normal)
67
68 --python-executable EXECUTABLE
69 Python executable used for finding PEP 561 compliant installed
70 packages and stubs
71
72 --no-site-packages
73 do not search for installed PEP 561 compliant packages
74
75 --no-silence-site-packages
76 Do not silence errors in PEP 561 compliant installed packages
77
78 platform configuration:
79 Type check code assuming certain runtime conditions.
80
81 --python-version x.y
82 type check code assuming it will be running on Python x.y
83
84 -2, --py2
85 use Python 2 mode (same as --python-version 2.7)
86
87 --platform PLATFORM
88 type check special-cased code for the given OS platform
89 (defaults to sys.platform)
90
91 --always-true NAME
92 additional variable to be considered True (may be repeated)
93
94 --always-false NAME
95 additional variable to be considered False (may be repeated)
96
97 Any type restrictions:
98 Disallow the use of the 'Any' type under certain conditions.
99
100 --disallow-any-unimported
101 disallow Any types resulting from unfollowed imports
102
103 --disallow-subclassing-any
104 disallow subclassing values of type 'Any' when defining classes
105 (inverse: --allow-subclassingany)
106
107 --disallow-any-expr
108 disallow all expressions that have type Any
109
110 --disallow-any-decorated
111 disallow functions that have Any in their signature after deco‐
112 rator transformation
113
114 --disallow-any-explicit
115 disallow explicit Any in type positions
116
117 --disallow-any-generics
118 disallow usage of generic types that do not specify explicit
119 type parameters
120
121 untyped definitions and calls:
122 Configure how untyped definitions and calls are handled.
123
124 --disallow-untyped-calls
125 disallow calling functions without type annotations from func‐
126 tions with type annotations (inverse: --allow-untyped-calls)
127
128 --disallow-untyped-defs
129 disallow defining functions without type annotations or with
130 incomplete type annotations (inverse: --allow-untyped-defs)
131
132 --disallow-incomplete-defs
133 disallow defining functions with incomplete type annotations
134 (inverse: --allow-incomplete-defs)
135
136 --check-untyped-defs
137 type check the interior of functions without type annotations
138 (inverse: --no-check-untyped-defs)
139
140 --warn-incomplete-stub
141 warn if missing type annotation in typeshed, only relevant with
142 --check-untyped-defs enabled (inverse: --no-warn-incom‐
143 plete-stub)
144
145 None and Optional handling:
146 Adjust how values of type 'None' are handled.
147
148 --no-implicit-optional
149 don't assume arguments with default values of None are Optional
150 (inverse: --implicit-optional)
151
152 --no-strict-optional
153 disable strict Optional checks (inverse: --strictoptional)
154
155 --strict-optional-whitelist [GLOB [GLOB ...]]
156 suppress strict Optional errors in all but the provided files;
157 implies --strict-optional (may suppress certain other errors in
158 non-whitelisted files)
159
160 warnings:
161 Detect code that is sound but redundant or problematic.
162
163 --warn-redundant-casts
164 warn about casting an expression to its inferred type (inverse:
165 --no-warn-redundant-casts)
166
167 --no-warn-no-return
168 do not warn about functions that end without returning (inverse:
169 --warn-no-return)
170
171 --warn-return-any
172 warn about returning values of type Any from nonAny typed func‐
173 tions (inverse: --no-warn-returnany)
174
175 --warn-unused-ignores
176 warn about unneeded '# type: ignore' comments (inverse:
177 --no-warn-unused-ignores)
178
179 other strictness checks:
180 Other miscellaneous strictness checks.
181
182 --disallow-untyped-decorators
183 disallow decorating typed functions with untyped decorators
184 (inverse: --allow-untyped-decorators)
185
186 --strict
187 strict mode; enables the following flags: --warnunused-configs,
188 --disallow-subclassing-any, --disallow-untyped-calls, --disal‐
189 low-untyped-defs, --disallow-incomplete-defs,
190 --check-untyped-defs, --no-implicit-optional, --warn-redun‐
191 dant-casts, --warn-return-any, --warn-unused-ignores, --disal‐
192 low-untyped-decorators
193
194 incremental mode:
195 Adjust how mypy incrementally type checks and caches modules.
196
197 --no-incremental
198 disable module cache (inverse: --incremental)
199
200 --cache-dir DIR
201 store module cache info in the given folder in incremental mode
202 (defaults to '.mypy_cache')
203
204 --cache-fine-grained
205 include fine-grained dependency information in the cache for the
206 mypy daemon
207
208 --quick-and-dirty
209 use cache even if dependencies out of date (implies --incremen‐
210 tal)
211
212 --skip-version-check
213 allow using cache written by older mypy version
214
215 mypy internals:
216 Debug and customize mypy internals.
217
218 --pdb invoke pdb on fatal error
219
220 --show-traceback, --tb
221 show traceback on fatal error
222
223 --custom-typing MODULE
224 use a custom typing module
225
226 --custom-typeshed-dir DIR
227 use the custom typeshed in DIR
228
229 --shadow-file SOURCE_FILE SHADOW_FILE
230 when encountering SOURCE_FILE, read and type check the contents
231 of SHADOW_FILE instead.
232
233 error reporting:
234 Adjust the amount of detail shown in error messages.
235
236 --show-error-context
237 precede errors with "note:" messages explaining context
238 (inverse: --hide-error-context)
239
240 --show-column-numbers
241 show column numbers in error messages (inverse: --hide-col‐
242 umn-numbers)
243
244 extra analysis:
245 Extract additional information and analysis.
246
247 --find-occurrences CLASS.MEMBER
248 print out all usages of a class member (experimental)
249
250 report generation:
251 Generate a report in the specified format.
252
253 --any-exprs-report DIR
254
255 --cobertura-xml-report DIR
256
257 --html-report DIR
258
259 --linecount-report DIR
260
261 --linecoverage-report DIR
262
263 --memory-xml-report DIR
264
265 --txt-report DIR
266
267 --xml-report DIR
268
269 --xslt-html-report DIR
270
271 --xslt-txt-report DIR
272
273 miscellaneous:
274 Other miscellaneous flags.
275
276 --junit-xml JUNIT_XML
277 write junit.xml to the given file
278
279 --scripts-are-modules
280 script x becomes module x instead of __main__
281
282 specifying which code to type check:
283 -m MODULE, --module MODULE
284 type-check module; can repeat for more modules
285
286 -p PACKAGE, --package PACKAGE
287 type-check package recursively; can be repeated
288
289 -c PROGRAM_TEXT, --command PROGRAM_TEXT
290 type-check program passed in as string
291
292 files type-check given files or directories
293
294 environment variables: Define MYPYPATH for additional module search
295 path entries.
296
297
298
299mypy 0.620-dev December 2018 MYPY(1)