I think Eric is talking about a mypy-specific keyword, since # type: ignore is also honored by other type checkers.

If I encounter an issue that's a false positive on mypy (like typing_extensions.Self), but other pyright recognizes correctly, then I can't ignore that line only for mypy.
On the other hand, I can silence pyright without it affecting mypy with # pyright: ignore.


---- ORIGINAL MESSAGE ----
Date:    2022-06-08 22:21:59 UTC+0200
From:    guido@python.org
To:      eric@traut.com
CC:      typing-sig@python.org
Subject: [Typing-sig] Re: Deprecate and remove type comments?
IIUC mypy already supports this syntax: https://mypy.readthedocs.io/en/stable/common_issues.html#spurious-errors-and-locally-silencing-the-checker

> 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 Error codes for more information.


On Wed, Jun 8, 2022 at 11:46 AM Eric Traut <eric@traut.com> wrote:
It strikes me as strange that the Python parser would have special-cased support for certain comments. I understand why this was done historically to support mypy specifically, but it's far from ideal.

This came up recently in a discussion (https://github.com/python/mypy/issues/12358) about adding support for an error suppression mechanism that is specific to mypy, something like `# mypy: ignore[x, y, z]`. Pyright already supports `# pyright: ignore[x, y, z]`, and it is increasingly common for code bases to use multiple type checkers.

Would it make sense to have a mode in the Python parser where it adds all comments to the AST — or at least all end-of-line comments? That way, mypy could invoke this parser mode and interpret the contents of comments any way it wants. It would get the Python parser out of the business of understanding specific comment formats.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org


--
--Guido van Rossum (python.org/~guido)

_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: dev@reggx.eu