Open
Description
blanket-type-ignore bans blanket # type: ignore
comments, however that's not entirely helpful for Pyright users.
The docs suggest to use # type: ignore[diagnosticRuleName]
instead, which Pyright sadly doesn't understand – it only accepts # pyright: ignore[diagnosticRuleName]
Would it be possible to expand this rule / create another one to only allow # pyright: ignore[diagnosticRuleName]
comments?
Pyright materials on # type: ignore
vs # pyright: ignore
microsoft/pyright#2877 (comment)
https://github.com/microsoft/pyright/blob/main/docs/comments.md#line-level-diagnostic-suppression
Example
Incorrect diagnostic rule caught by Pyright:

# type: ignore[ruleThatDoesNotExist]
interpreted as # type: ignore
by Pyright:

Activity
kkom commentedon Sep 27, 2024
I guess we could have two rules:
One that bans blanket type ignore comments (regardless of whether it's the vanilla or pyright one) -- the one I referred to could be expanded like this
Another that bans the vanilla "type: ignore" comment, in favour of the pyright version -- that would need to be new I think
That is, if you're happy to have some Pyright specific rules in Ruff!
MichaReiser commentedon Sep 28, 2024
Extending
blanked-type-ignore
to also lint forpyright: ignore
without a rule code seems reasonable.Isn't this covered by by using a combination of
blanked-type-ignore
(which flags all blank ignore codes) and running pyright (which flags a type error everywhere where someone usestype: ignore[code]
)? Or does pyright ignore all codes when usingtype: ignore[code]
?kkom commentedon Sep 28, 2024
Yeah, the problem is that Pyright treats both of these as a blanket ignore: