Suggest inserting `# pyright: ignore` without `enableTypeIgnoreComments`
After #4494 quick actions now have an option to insert # pyright: ignore[xxx] instead of generic # type: ignore, which is very useful, especially combined with reportUnnecessaryTypeIgnoreComment = true, so each comment basically becomes a direct typing test.
But, as described in https://github.com/microsoft/pylance-release/issues/5565#issuecomment-1974327350, it only works if pyright's enableTypeIgnoreComments is enabled. If this option is enabled, then # type: ignore have no effect and inserting # pyright: ignore becomes a necessity, makes sense.
The thing is, sometimes you meet a general issue, that any type checker would report, and then # type: ignore does come in handy and enabling enableTypeIgnoreComments is kind of assumes that everyone using a codebase is using pyright only and the only way to get rid of the type error is to double ignore it as shown below, which doesn't look good in general.
foo(bar) # pyright: ignore[reportRedeclaration] # type: ignore
But sometimes you're just working around pyright quirks and inserting # pyright: ignore[xxx] fits the best.
My proposals:
-
add better documentation for the current workflow, to make "enableTypeIgnoreComments" -> "available quick action for inserting pyright ignore comments" connection more discoverable. Which I guess is kind of part of #7163
-
to show both options in Quick Actions, so user could decide what fits the best for the current situation. Though option to insert
# type: ignoreprobably should be hidden ifenableTypeIgnoreCommentsistrue, to avoid return of #4494.
Thanks for the issue. I agree that the user should have a choice here.
This issue has been fixed in prerelease version 2025.6.101, which we've just released. You can find the changelog here: CHANGELOG.md
Thank you, works a like a charm.
hello @debonte h