Skip to content

Commit f4a919a

Browse files
committed
Allow type: ignore error codes filtering
1 parent dece44f commit f4a919a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

conformance/tests/directives_type_ignore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
y: int = "" # type: ignore - additional stuff
1212

1313
# The following type violation should be suppressed.
14-
z: int = "" # type: ignore[additional_stuff]
14+
z: int = "" # type: ignore[assignment]
1515

1616
# > In some cases, linting tools or other comments may be needed on the same
1717
# > line as a type comment. In these cases, the type comment should be before

docs/spec/directives.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ other comments and linting markers:
7373

7474
# type: ignore # <comment or other marker>
7575

76+
Any text following ``# type: ignore`` is ignored, provided there is at least one
77+
whitespace character after ``# type: ignore``. The form of
78+
``# type: ignore[error_code1, error_code2]`` can be used to filter error codes
79+
that may vary across type checkers. Type checkers may ignore the bracketed
80+
codes and treat this form as equivalent to ``# type: ignore``.
81+
82+
7683
.. _`cast`:
7784

7885
``cast()``

0 commit comments

Comments
 (0)