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

NAME

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