Skip to content

Commit 09c1fc7

Browse files
jolafMichael0x2a
authored andcommitted
Update config file doc to match command line doc and --help (#7776)
This pull request reorganizes the command line docs, the config file docs, and the output of `--help` so they all list the options in the same order and all use the same section heading titles. It also adds a few previously undocumented flags to the docs, such as `--pretty` and several of the report generation flags. As a part of this cleanup, this PR also makes two minor changes to the flags themselves: `--custom-typing` was renamed to `--custom-typing-module` and the `--strict-optional-whitelist` flag was deprecated. Fixes #7574, #7575, #7772.
1 parent 10428ed commit 09c1fc7

File tree

4 files changed

+326
-211
lines changed

4 files changed

+326
-211
lines changed

docs/source/command_line.rst

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ for full details, see :ref:`running-mypy`.
4444
Asks mypy to type check the provided string as a program.
4545

4646

47+
Optional arguments
48+
******************
49+
50+
``-h`` / ``--help``
51+
Show help message and exit.
52+
53+
``-v`` / ``--verbose``
54+
More verbose messages.
55+
56+
``-V`` / ``--version``
57+
Show program's version number and exit.
58+
4759
.. _config-file-flag:
4860

4961
Config file
@@ -87,7 +99,7 @@ imports.
8799
module search path -- this is primarily set from the source files
88100
passed on the command line, the ``MYPYPATH`` environment variable,
89101
and the :ref:`mypy_path config option
90-
<config-file-import-discovery-global>`.
102+
<config-file-import-discovery>`.
91103

92104
Note that this only affects import discovery -- for modules and
93105
packages explicitly passed on the command line, mypy still
@@ -192,6 +204,7 @@ For more information on how to use these flags, see :ref:`version_and_platform_c
192204
compile-time constants that are always false. This flag may
193205
be repeated.
194206

207+
195208
.. _disallow-dynamic-typing:
196209

197210
Disallow dynamic typing
@@ -247,6 +260,7 @@ The following options are available:
247260
the base class even though that may not actually be the case. This
248261
flag makes mypy raise an error instead.
249262

263+
250264
.. _untyped-definitions-and-calls:
251265

252266
Untyped definitions and calls
@@ -280,6 +294,7 @@ definitions or calls.
280294
This flag reports an error whenever a function with type annotations
281295
is decorated with a decorator without annotations.
282296

297+
283298
.. _none-and-optional-handling:
284299

285300
None and Optional handling
@@ -317,11 +332,11 @@ For more details, see :ref:`no_strict_optional`.
317332
generally check the use of ``None`` values -- they are valid
318333
everywhere. See :ref:`no_strict_optional` for more about this feature.
319334

320-
.. note::
321-
Strict optional checking was enabled by default starting in
335+
**Note:** Strict optional checking was enabled by default starting in
322336
mypy 0.600, and in previous versions it had to be explicitly enabled
323337
using ``--strict-optional`` (which is still accepted).
324338

339+
325340
.. _configuring-warnings:
326341

327342
Configuring warnings
@@ -469,6 +484,7 @@ of the above sections.
469484
Note: the exact list of flags enabled by running ``--strict`` may change
470485
over time.
471486

487+
472488
.. _configuring-error-messages:
473489

474490
Configuring error messages
@@ -511,6 +527,10 @@ in error messages.
511527

512528
See :ref:`error-codes` for more information.
513529

530+
``--pretty``
531+
Use visually nicer output in error messages: use soft word wrap,
532+
show source code snippets, and show error location markers.
533+
514534
``--no-color-output``
515535
This flag will disable color output in error messages, enabled by default.
516536

@@ -519,6 +539,10 @@ in error messages.
519539
including total number of errors, number of files with errors, and number
520540
of files checked.
521541

542+
``--show-absolute-path``
543+
Show absolute paths to files.
544+
545+
522546
.. _incremental:
523547

524548
Incremental mode
@@ -556,14 +580,22 @@ beyond what incremental mode can offer, try running mypy in
556580
writing to the cache, use ``--cache-dir=/dev/null`` (UNIX)
557581
or ``--cache-dir=nul`` (Windows).
558582

583+
``--sqlite-cache``
584+
Use an `SQLite`_ database to store the cache.
585+
586+
``--cache-fine-grained``
587+
Include fine-grained dependency information in the cache for the mypy daemon.
588+
559589
``--skip-version-check``
560590
By default, mypy will ignore cache data generated by a different
561591
version of mypy. This flag disables that behavior.
562592

563-
.. _advanced-flags:
593+
``--skip-cache-mtime-checks``
594+
Skip cache internal consistency checks based on mtime.
595+
564596

565-
Advanced flags
566-
**************
597+
Advanced options
598+
****************
567599

568600
The following flags are useful mostly for people who are interested
569601
in developing or debugging mypy internals.
@@ -576,7 +608,10 @@ in developing or debugging mypy internals.
576608
If set, this flag will display a full traceback when mypy
577609
encounters a fatal error.
578610

579-
``--custom-typing MODULE``
611+
``--raise-exceptions``
612+
Raise exception on fatal error.
613+
614+
``--custom-typing-module MODULE``
580615
This flag lets you use a custom module as a substitute for the
581616
:py:mod:`typing` module.
582617

@@ -622,6 +657,7 @@ in developing or debugging mypy internals.
622657
cause mypy to type check the contents of ``temp.py`` instead of ``original.py``,
623658
but error messages will still reference ``original.py``.
624659

660+
625661
Report generation
626662
*****************
627663

@@ -632,6 +668,16 @@ format into the specified directory.
632668
Causes mypy to generate a text file report documenting how many
633669
expressions of type ``Any`` are present within your codebase.
634670

671+
``--cobertura-xml-report DIR``
672+
Causes mypy to generate a Cobertura XML type checking coverage report.
673+
674+
You must install the `lxml`_ library to generate this report.
675+
676+
``--html-report`` / ``--xslt-html-report DIR``
677+
Causes mypy to generate an HTML type checking coverage report.
678+
679+
You must install the `lxml`_ library to generate this report.
680+
635681
``--linecount-report DIR``
636682
Causes mypy to generate a text file report documenting the functions
637683
and lines that are typed and untyped within your codebase.
@@ -641,30 +687,29 @@ format into the specified directory.
641687
absolute filename to a list of line numbers that belong to typed
642688
functions in that file.
643689

644-
``--cobertura-xml-report DIR``
645-
Causes mypy to generate a Cobertura XML type checking coverage report.
690+
``--lineprecision-report DIR``
691+
Causes mypy to generate a flat text file report with per-module
692+
statistics of how many lines are typechecked etc.
693+
694+
``--txt-report`` / ``--xslt-txt-report DIR``
695+
Causes mypy to generate a text file type checking coverage report.
646696

647697
You must install the `lxml`_ library to generate this report.
648698

649-
``--html-report DIR``, ``--xslt-html-report DIR``
650-
Causes mypy to generate an HTML type checking coverage report.
699+
``--xml-report DIR``
700+
Causes mypy to generate an XML type checking coverage report.
651701

652702
You must install the `lxml`_ library to generate this report.
653703

654-
``--txt-report DIR``, ``--xslt-txt-report DIR``
655-
Causes mypy to generate a text file type checking coverage report.
656704

657-
You must install the `lxml`_ library to generate this report.
705+
Miscellaneous
706+
*************
658707

659708
``--junit-xml JUNIT_XML``
660709
Causes mypy to generate a JUnit XML test result document with
661710
type checking results. This can make it easier to integrate mypy
662711
with continuous integration (CI) tools.
663712

664-
665-
Miscellaneous
666-
*************
667-
668713
``--find-occurrences CLASS.MEMBER``
669714
This flag will make mypy print out all usages of a class member
670715
based on static type information. This feature is experimental.
@@ -681,3 +726,4 @@ Miscellaneous
681726
by this flag is often more convenient.)
682727

683728
.. _lxml: https://pypi.org/project/lxml/
729+
.. _SQLite: https://www.sqlite.org/

0 commit comments

Comments
 (0)