Skip to content
2 changes: 1 addition & 1 deletion conformance/tests/directives_type_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
y: int = "" # type: ignore - additional stuff

# The following type violation should be suppressed.
Comment thread
davidhalter marked this conversation as resolved.
Outdated
z: int = "" # type: ignore[additional_stuff]
z: int = "" # type: ignore[assignment]
Comment thread
carljm marked this conversation as resolved.
Outdated

# > In some cases, linting tools or other comments may be needed on the same
# > line as a type comment. In these cases, the type comment should be before
Expand Down
7 changes: 7 additions & 0 deletions docs/spec/directives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ other comments and linting markers:

# type: ignore # <comment or other marker>

Any text following ``# type: ignore`` is ignored, provided there is at least one
whitespace character after ``# type: ignore``. The form of
``# type: ignore[error_code1, error_code2]`` can be used to filter error codes
Comment thread
davidhalter marked this conversation as resolved.
Outdated
that may vary across type checkers. Type checkers may ignore the bracketed
codes and treat this form as equivalent to ``# type: ignore``.


.. _`cast`:

``cast()``
Expand Down