astral-sh/ruff#17305 revealed an interesting case where Red Knot raised an unused suppression diagnostic when the user intended to suppress it:
text_encoding = (
io.text_encoding # type: ignore[unused-ignore, attr-defined]
if sys.version_info > (3, 10)
else _text_encoding
)
Source: https://github.com/jaraco/zipp/blob/main/zipp/compat/py310.py
type: ignore currently acts as a wildcard suppression (we disregard anything coming in [...]) and suppresses anything except unused suppression issues. The result is that users aren't able to suppress unused suppression diagnostics with type: ignore and are forced to use a red knot specific suppression instead.
Different options are:
- Change
type: ignore to suppress all diagnostics (including unused suppression)
- Accept that users have to use a red knot specific suppression for unused suppression diagnostics (this is what Ruff does)
- Add support for
type: ignore[unused-ignore]
- ..?
astral-sh/ruff#17305 revealed an interesting case where Red Knot raised an unused suppression diagnostic when the user intended to suppress it:
Source: https://github.com/jaraco/zipp/blob/main/zipp/compat/py310.py
type: ignorecurrently acts as a wildcard suppression (we disregard anything coming in[...]) and suppresses anything except unused suppression issues. The result is that users aren't able to suppress unused suppression diagnostics withtype: ignoreand are forced to use a red knot specific suppression instead.Different options are:
type: ignoreto suppress all diagnostics (including unused suppression)type: ignore[unused-ignore]