Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document error codes #7451

Merged
merged 14 commits into from Sep 18, 2019
12 changes: 10 additions & 2 deletions docs/source/command_line.rst
Expand Up @@ -497,12 +497,20 @@ in error messages.
main.py:3: error: Unsupported operand types for + ("int" and "str")

``--show-column-numbers``
This flag will add column offsets to error messages,
for example, the following indicates an error in line 12, column 9
This flag will add column offsets to error messages.
For example, the following indicates an error in line 12, column 9
(note that column offsets are 0-based)::

main.py:12:9: error: Unsupported operand types for / ("int" and "str")

``--show-error-codes``
This flag will add an error code ``[<code>]`` to error messages. The error
code is shown after each error message::

prog.py:1: error: "str" has no attribute "trim" [attr-defined]

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

``--no-color-output``
This flag will disable color output in error messages, enabled by default.

Expand Down
8 changes: 8 additions & 0 deletions docs/source/common_issues.rst
Expand Up @@ -124,6 +124,14 @@ error:
The second line is now fine, since the ignore comment causes the name
``frobnicate`` to get an implicit ``Any`` type.

.. note::

You can use the form ``# type: ignore[<code>]`` to only ignore
specific errors on the line. This way you are less likely to
silence unexpected errors that are not safe to ignore, and this
will also document what the purpose of the comment is. See
:ref:`error-codes` for more information.

.. note::

The ``# type: ignore`` comment will only assign the implicit ``Any``
Expand Down
4 changes: 4 additions & 0 deletions docs/source/config_file.rst
Expand Up @@ -441,12 +441,16 @@ section of the command line docs.
``show_column_numbers`` (bool, default False)
Shows column numbers in error messages.

``show_error_codes`` (bool, default False)
Shows error codes in error messages. See :ref:`error-codes` for more information.

``color_output`` (bool, default True)
Shows error messages with color enabled.

``error_summary`` (bool, default True)
Shows a short summary line after error messages.


Advanced options
----------------

Expand Down