diff --git a/conformance/tests/directives_type_ignore.py b/conformance/tests/directives_type_ignore.py index b96d23ae..f76802b9 100644 --- a/conformance/tests/directives_type_ignore.py +++ b/conformance/tests/directives_type_ignore.py @@ -11,7 +11,7 @@ y: int = "" # type: ignore - additional stuff # The following type violation should be suppressed. -z: int = "" # type: ignore[additional_stuff] +z: int = "" # type: ignore[assignment] # > 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 diff --git a/docs/spec/directives.rst b/docs/spec/directives.rst index 6ed7016a..927c4081 100644 --- a/docs/spec/directives.rst +++ b/docs/spec/directives.rst @@ -73,6 +73,13 @@ other comments and linting markers: # type: ignore # +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 +that may vary across type checkers. Type checkers may ignore the bracketed +codes and treat this form as equivalent to ``# type: ignore``. + + .. _`cast`: ``cast()``