@@ -16,17 +16,17 @@ flag (or its long form ``--help``)::
16
16
[--warn-incomplete-stub] [--warn-redundant-casts]
17
17
[--warn-no-return] [--warn-unused-ignores] [--show-error-context]
18
18
[--fast-parser] [-i] [--cache-dir DIR] [--strict-optional]
19
- [--strict-optional-whitelist [GLOB [GLOB ...]]]
19
+ [--strict-optional-whitelist [GLOB [GLOB ...]]] [--strict]
20
20
[--junit-xml JUNIT_XML] [--pdb] [--show-traceback] [--stats]
21
21
[--inferstats] [--custom-typing MODULE]
22
22
[--custom-typeshed-dir DIR] [--scripts-are-modules]
23
23
[--config-file CONFIG_FILE] [--show-column-numbers]
24
- [--find-occurrences CLASS.MEMBER] [--cobertura-xml-report DIR ]
25
- [--html- report DIR] [--linecount -report DIR]
26
- [--linecoverage -report DIR] [--memory-xml -report DIR]
27
- [--old-html -report DIR] [--txt-report DIR] [--xml -report DIR]
28
- [--xslt-html- report DIR] [--xslt-txt- report DIR] [-m MODULE ]
29
- [-c PROGRAM_TEXT] [-p PACKAGE]
24
+ [--find-occurrences CLASS.MEMBER] [--strict-boolean ]
25
+ [--cobertura-xml- report DIR] [--html -report DIR]
26
+ [--linecount -report DIR] [--linecoverage -report DIR]
27
+ [--memory-xml -report DIR] [--old-html -report DIR]
28
+ [--txt- report DIR] [--xml- report DIR] [--xslt-html-report DIR ]
29
+ [--xslt-txt-report DIR] [-m MODULE] [- c PROGRAM_TEXT] [-p PACKAGE]
30
30
[files [files ...]]
31
31
32
32
(etc., too long to show everything here)
@@ -345,9 +345,9 @@ Here are some more useful flags:
345
345
346
346
- ``--config-file CONFIG_FILE `` causes configuration settings to be
347
347
read from the given file. By default settings are read from ``mypy.ini ``
348
- in the current directory. Settings override mypy's built-in defaults
349
- and command line flags can override settings. See :ref: ` config-file `
350
- for the syntax of configuration files.
348
+ or `` setup.cfg `` in the current directory. Settings override mypy's
349
+ built-in defaults and command line flags can override settings.
350
+ See :ref: ` config-file ` for the syntax of configuration files.
351
351
352
352
- ``--junit-xml JUNIT_XML `` will make mypy generate a JUnit XML test
353
353
result document with type checking results. This can make it easier
@@ -366,6 +366,17 @@ Here are some more useful flags:
366
366
also currently ignores functions with an empty body or a body that is
367
367
just ellipsis (``... ``), since these can be valid as abstract methods.
368
368
369
+ - ``--warn-return-any `` causes mypy to generate a warning when returning a value
370
+ with type ``Any `` from a function declared with a non- ``Any `` return type.
371
+
372
+ - ``--strict-boolean `` will make using non-boolean expressions in conditions
373
+ an error. This means ``if x `` and ``while x `` are disallowed when ``x `` has any
374
+ type other than ``bool ``. Instead use explicit checks like ``if x > 0 `` or
375
+ ``while x is not None ``.
376
+
377
+ - ``--strict `` mode enables all optional error checking flags. You can see the
378
+ list of flags enabled by strict mode in the full ``mypy -h `` output.
379
+
369
380
For the remaining flags you can read the full ``mypy -h `` output.
370
381
371
382
.. note ::
@@ -378,20 +389,21 @@ Integrating mypy into another Python application
378
389
************************************************
379
390
380
391
It is possible to integrate mypy into another Python 3 application by
381
- importing ``mypy.api `` and calling the ``run `` function with exactly the string
382
- you would have passed to mypy from the command line.
392
+ importing ``mypy.api `` and calling the ``run `` function with a parameter of type `` List[str] ``, containing
393
+ what normally would have been the command line arguments to mypy .
383
394
384
- Function ``run `` returns a tuple of strings:
385
- ``(<normal_report>, <error_report>) ``, in which ``<normal_report> `` is what mypy
386
- normally writes to ``sys.stdout `` and ``<error_report> `` is what mypy normally
387
- writes to ``sys.stderr ``.
395
+ Function ``run `` returns a ``Tuple[str, str, int] ``, namely
396
+ ``(<normal_report>, <error_report>, <exit_status>) ``, in which ``<normal_report> ``
397
+ is what mypy normally writes to ``sys.stdout ``, ``<error_report> `` is what mypy
398
+ normally writes to ``sys.stderr `` and ``exit_status `` is the exit status mypy normally
399
+ returns to the operating system.
388
400
389
- A trivial example of this is the following::
401
+ A trivial example of using the api is the following::
390
402
391
403
import sys
392
404
from mypy import api
393
405
394
- result = api.run(' '.join( sys.argv[1:]) )
406
+ result = api.run(sys.argv[1:])
395
407
396
408
if result[0]:
397
409
print('\nType checking report:\n')
@@ -400,3 +412,5 @@ A trivial example of this is the following::
400
412
if result[1]:
401
413
print('\nError report:\n')
402
414
print(result[1]) # stderr
415
+
416
+ print ('\nExit status:', result[2])
0 commit comments