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

NAME

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