From eb6282b4a73f7cd5b985f9ac055a76b6ad7dd70a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 22 May 2019 08:22:39 -0700 Subject: [PATCH] Change specification for `# type: ignore` (#1072) As discussed on the typing-sig mailing list, the currently specified behavior for `# type: ignore` on a line by itself has remained mostly unimplemented and doesn't seem useful. Instead, the PEP now mandates a syntax for ignoring all errors in a specific file, which is more obviously useful. I considered adding a sentence like "Individual type checkers may add additional syntax for silencing errors", but it didn't seem particularly useful since type checkers in general are free to add extensions to what PEP 484 specifies. While I was at it I added a reference to PEP 526 to an out-of-date sentence adjacent to the modified paragraph. --- pep-0484.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pep-0484.txt b/pep-0484.txt index 0da640594..d6b0da5a8 100644 --- a/pep-0484.txt +++ b/pep-0484.txt @@ -1515,10 +1515,10 @@ error refers to:: 'not_found': http.client.NOT_FOUND # type: ignore } -A ``# type: ignore`` comment on a line by itself is equivalent to -adding an inline ``# type: ignore`` to each line until the end of -the current indented block. At top indentation level this has -effect of disabling type checking until the end of file. +A ``# type: ignore`` comment on a line by itself at the top of a file, +before any docstrings, imports, or other executable code, silences all +errors in the file. Blank lines and other comments, such as shebang +lines and coding cookies, may precede the ``# type: ignore`` comment. 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 @@ -1527,7 +1527,8 @@ other comments and linting markers: # type: ignore # If type hinting proves useful in general, a syntax for typing variables -may be provided in a future Python version. +may be provided in a future Python version. (**UPDATE**: This syntax +was added in Python 3.6 through PEP 526.) Casts =====