You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is working as designed. As with pylint, pyright emits reportUnnecessaryTypeIgnoreComment diagnostics only when removing that comment produces no diagnostics by pyright. Pyright has no way of knowing whether mypy will produce an error on a particular line, nor should it.
If you are running both mypy and pyright on your code base, you will need to contend with the inevitable differences between the two. Pyright supports a pyright-specific diagnostic suppression mechanism through the use of # pyright: ignore comments. Mypy unfortunately doesn't have an equivalent. Ideally, you would be able to use # mypy: ignore, but this is technically difficult for mypy to support because of its reliance on the Python parser. See this issue for details. Because of this, you will need to decide whether you want to use pyright or mypy as a type checker (rather than both), or you can disable reportUnnecessaryTypeIgnoreComment.
In any case, this is not a bug. Pyright and pylance are working as expected here.
Environment data
Code Snippet
After placing a type ignore on the following
pylance
errorpylance
incorrectly warns that the type ignore is redundant:The same behavior occurs with all errors attempted to be ignored, regardless of whether the syntax is
# pyright: ignore
or# type: ignore
.Repro Steps
mypy 0.961
is being run invscode 1.68.1
. The project uses apyproject.toml
with the followingmypy
settings:and a user (global) level
settings.json
configured to run thedmypy.exe
daemon:Expected behavior
pylint
only warns aboutunnecessary type ignore
s when removing them will actually not yield an error (i.e. they are actually unnecessary).Update
This may not be a bug if this is expected behavior when
is used. However, perhaps these are conflicting settings when used in conjunction?
The text was updated successfully, but these errors were encountered: