1MYPY(1)                          User Commands                         MYPY(1)
2
3
4

NAME

6       mypy - manual page for mypy 0.740-dev
7

DESCRIPTION

9       usage: mypy [-h] [-v] [-V] [more options; see below]
10
11              [-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
12
13       Mypy is a program that will type check your Python code.
14
15       Pass  in  any files or folders you want to type check. Mypy will recur‐
16       sively traverse any provided folders to find .py files:
17
18              $ mypy my_program.py my_src_folder
19
20       For more information on getting started, see:
21
22       - http://mypy.readthedocs.io/en/latest/getting_started.html
23
24       For more details on both running mypy and using the flags below, see:
25
26       -       http://mypy.readthedocs.io/en/latest/running_mypy.html        -
27       http://mypy.readthedocs.io/en/latest/command_line.html
28
29       You  can also use a config file to configure mypy instead of using com‐
30       mand line flags. For more details, see:
31
32       - http://mypy.readthedocs.io/en/latest/config_file.html
33
34   Optional arguments:
35       -h, --help
36              Show this help message and exit
37
38       -v, --verbose
39              More verbose messages
40
41       -V, --version
42              Show program's version number and exit
43
44   Config file:
45              Use a config file instead of command  line  arguments.  This  is
46              useful  if  you  are  using  many flags or want to set different
47              options per each module.
48
49       --config-file CONFIG_FILE
50              Configuration file, must have  a  [mypy]  section  (defaults  to
51              mypy.ini, setup.cfg, ~/.config/mypy/config, ~/.mypy.ini)
52
53       --warn-unused-configs
54              Warn  about  unused '[mypy-<pattern>]' config sections (inverse:
55              --no-warn-unused-configs)
56
57   Import discovery:
58              Configure how imports are discovered and followed.
59
60       --ignore-missing-imports
61              Silently ignore imports of missing modules
62
63       --follow-imports {normal,silent,skip,error}
64              How to treat imports (default normal)
65
66       --python-executable EXECUTABLE
67              Python executable used for finding PEP 561  compliant  installed
68              packages and stubs
69
70       --no-site-packages
71              Do not search for installed PEP 561 compliant packages
72
73       --no-silence-site-packages
74              Do not silence errors in PEP 561 compliant installed packages
75
76       --namespace-packages
77              Support  namespace packages (PEP 420, __init__.pyless) (inverse:
78              --no-namespace-packages)
79
80   Platform configuration:
81              Type check code assuming it will be run  under  certain  runtime
82              conditions.   By  default,  mypy  assumes  your code will be run
83              using the same operating system and Python version you are using
84              to run mypy itself.
85
86       --python-version x.y
87              Type check code assuming it will be running on Python x.y
88
89       -2, --py2
90              Use Python 2 mode (same as --python-version 2.7)
91
92       --platform PLATFORM
93              Type   check  special-cased  code  for  the  given  OS  platform
94              (defaults to sys.platform)
95
96       --always-true NAME
97              Additional variable to be considered True (may be repeated)
98
99       --always-false NAME
100              Additional variable to be considered False (may be repeated)
101
102   Dynamic typing:
103              Disallow the use of the dynamic 'Any' type under certain  condi‐
104              tions.
105
106       --disallow-any-unimported
107              Disallow Any types resulting from unfollowed imports
108
109       --disallow-subclassing-any
110              Disallow  subclassing values of type 'Any' when defining classes
111              (inverse: --allow-subclassingany)
112
113       --disallow-any-expr
114              Disallow all expressions that have type Any
115
116       --disallow-any-decorated
117              Disallow functions that have Any in their signature after  deco‐
118              rator transformation
119
120       --disallow-any-explicit
121              Disallow explicit Any in type positions
122
123       --disallow-any-generics
124              Disallow  usage  of  generic  types that do not specify explicit
125              type parameters (inverse: --allow-any-generics)
126
127   Untyped definitions and calls:
128              Configure how untyped definitions and calls are  handled.  Note:
129              by  default,  mypy  ignores any untyped function definitions and
130              assumes any calls to such functions have a return type of 'Any'.
131
132       --disallow-untyped-calls
133              Disallow calling functions without type annotations  from  func‐
134              tions with type annotations (inverse: --allow-untyped-calls)
135
136       --disallow-untyped-defs
137              Disallow  defining  functions  without  type annotations or with
138              incomplete type annotations (inverse: --allow-untyped-defs)
139
140       --disallow-incomplete-defs
141              Disallow defining functions  with  incomplete  type  annotations
142              (inverse: --allow-incomplete-defs)
143
144       --check-untyped-defs
145              Type  check  the  interior of functions without type annotations
146              (inverse: --no-check-untyped-defs)
147
148       --disallow-untyped-decorators
149              Disallow decorating  typed  functions  with  untyped  decorators
150              (inverse: --allow-untyped-decorators)
151
152   None and Optional handling:
153              Adjust  how  values of type 'None' are handled. For more context
154              on   how   mypy   handles   values   of   type   'None',    see:
155              http://mypy.readthedocs.io/en/lat
156              est/kinds_of_types.html#no-strictoptional
157
158       --no-implicit-optional
159              Don't assume arguments with default values of None are  Optional
160              (inverse: --implicit-optional)
161
162       --no-strict-optional
163              Disable strict Optional checks (inverse: --strictoptional)
164
165       --strict-optional-whitelist [GLOB [GLOB ...]]
166              Suppress  strict  Optional errors in all but the provided files;
167              implies --strict-optional (may suppress certain other errors  in
168              non-whitelisted files)
169
170   Warnings:
171              Detect code that is sound but redundant or problematic.
172
173       --warn-redundant-casts
174              Warn  about casting an expression to its inferred type (inverse:
175              --no-warn-redundant-casts)
176
177       --warn-unused-ignores
178              Warn  about  unneeded  '#  type:  ignore'   comments   (inverse:
179              --no-warn-unused-ignores)
180
181       --no-warn-no-return
182              Do not warn about functions that end without returning (inverse:
183              --warn-no-return)
184
185       --warn-return-any
186              Warn about returning values of type Any from nonAny typed  func‐
187              tions (inverse: --no-warn-returnany)
188
189       --warn-unreachable
190              Warn  about statements or expressions inferred to be unreachable
191              or redundant (inverse: --no-warnunreachable)
192
193   Other strictness checks:
194       --allow-untyped-globals
195              Suppress toplevel errors caused by missing annotations (inverse:
196              --disallow-untyped-globals)
197
198       --allow-redefinition
199              Allow  unconditional  variable  redefinition  with  a  new  type
200              (inverse: --disallow-redefinition)
201
202       --strict-equality
203              Prohibit equality, identity, and container checks for  non-over‐
204              lapping types (inverse: --no-strictequality)
205
206       --no-implicit-reexport
207              Treat    imports    as    private   unless   aliased   (inverse:
208              --implicit-reexport)
209
210       --strict
211              Strict mode; enables the following flags:  --warnunused-configs,
212              --disallow-subclassing-any,   --disallow-any-generics,  --disal‐
213              low-untyped-calls,  --disallow-untyped-defs,   --disallow-incom‐
214              pletedefs,  --check-untyped-defs,  --disallow-untypeddecorators,
215              --no-implicit-optional,                   --warnredundant-casts,
216              --warn-unused-ignores, --warnreturn-any, --no-implicit-reexport
217
218   Incremental mode:
219              Adjust  how  mypy  incrementally type checks and caches modules.
220              Mypy caches type information about modules into a cache  to  let
221              you  speed up future invocations of mypy. Also see mypy's daemon
222              mode: mypy.readthedocs.io/en/latest/mypy_daemon.html#mypy-daemon
223
224       --no-incremental
225              Disable module cache (inverse: --incremental)
226
227       --cache-dir DIR
228              Store module cache info in the given folder in incremental  mode
229              (defaults to '.mypy_cache')
230
231       --sqlite-cache
232              Use   a   sqlite   database   to   store   the  cache  (inverse:
233              --no-sqlite-cache)
234
235       --cache-fine-grained
236              Include fine-grained dependency information in the cache for the
237              mypy daemon
238
239       --skip-version-check
240              Allow using cache written by older mypy version
241
242       --skip-cache-mtime-checks
243              Skip cache internal consistency checks based on mtime
244
245   Mypy internals:
246              Debug and customize mypy internals.
247
248       --pdb  Invoke pdb on fatal error
249
250       --show-traceback, --tb
251              Show traceback on fatal error
252
253       --raise-exceptions
254              Raise exception on fatal error
255
256       --custom-typing MODULE
257              Use a custom typing module
258
259       --custom-typeshed-dir DIR
260              Use the custom typeshed in DIR
261
262       --warn-incomplete-stub
263              Warn  if missing type annotation in typeshed, only relevant with
264              --disallow-untyped-defs  or  --disallow-incomplete-defs  enabled
265              (inverse: --nowarn-incomplete-stub)
266
267       --shadow-file SOURCE_FILE SHADOW_FILE
268              When  encountering SOURCE_FILE, read and type check the contents
269              of SHADOW_FILE instead.
270
271   Error reporting:
272              Adjust the amount of detail shown in error messages.
273
274       --show-error-context
275              Precede  errors  with  "note:"   messages   explaining   context
276              (inverse: --hide-error-context)
277
278       --show-column-numbers
279              Show  column  numbers  in  error  messages (inverse: --hide-col‐
280              umn-numbers)
281
282       --show-error-codes
283              Show error codes in error messages (inverse: --hide-error-codes)
284
285       --pretty
286              Use visually nicer output in error messages: Use soft word wrap,
287              show  source code snippets, and error location markers (inverse:
288              --no-pretty)
289
290       --no-color-output
291              Do not colorize error messages (inverse: --coloroutput)
292
293       --no-error-summary
294              Do not show error stats summary (inverse: --errorsummary)
295
296   Report generation:
297              Generate a report in the specified format.
298
299       --any-exprs-report DIR
300
301       --cobertura-xml-report DIR
302
303       --html-report DIR
304
305       --linecount-report DIR
306
307       --linecoverage-report DIR
308
309       --lineprecision-report DIR
310
311       --memory-xml-report DIR
312
313       --txt-report DIR
314
315       --xml-report DIR
316
317       --xslt-html-report DIR
318
319       --xslt-txt-report DIR
320
321   Miscellaneous:
322       --junit-xml JUNIT_XML
323              Write junit.xml to the given file
324
325       --scripts-are-modules
326              Script x becomes module x instead of __main__
327
328       --find-occurrences CLASS.MEMBER
329              Print out all usages of a class member (experimental)
330
331   Running code:
332              Specify the code you want to type check. For more  details,  see
333              mypy.readthedocs.io/en/latest/running_mypy.html#running-mypy
334
335       -m MODULE, --module MODULE
336              Type-check module; can repeat for more modules
337
338       -p PACKAGE, --package PACKAGE
339              Type-check package recursively; can be repeated
340
341       -c PROGRAM_TEXT, --command PROGRAM_TEXT
342              Type-check program passed in as string
343
344       files  Type-check given files or directories
345
346   Environment variables:
347              Define  MYPYPATH  for  additional  module  search  path entries.
348              Define MYPY_CACHE_DIR to override configuration cache_dir path.
349
350
351
352mypy 0.740-dev                   November 2019                         MYPY(1)
Impressum