DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server

Home Page:https://docs.basedpyright.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`type: ignore[...]` silences all errors

amadanmath opened this issue · comments

Using this code as an example (verified on basedpyright.com):

class Foo: pass
Foo(1)

There is an reportUnusedCallResult and reportCallIssue on line 2.

Attaching # pyright: ignore[reportCallIssue], the remaining reportUnusedCallResult is still identified, as expected.

However, # type: ignore[reportCallIssue] will silence all errors. Is this intended? The README suggests it is not:

it's good practice to specify an error code in your pyright:ignore/type:ignore comments:

# type:ignore[reportUnreachable]

this way, if the error changes or a new error appears on the same line in the future, you'll get a new error because the comment doesn't account for the other error

yeah type:ignore is pretty unsafe, it doesn't even warn you if the rule doesn't exist, which is an upstream issue.

i can only imagine the reasoning for this was to prevent pyright from complaining about type:ignore comments intended for mypy if you're using both type checkers, since mypy has different error codes. but in that case you should just disable enableTypeIgnoreComments which makes pyright ignore them entirely.

i think the fix is to deprecate enableTypeIgnoreComments, make it disabled by default, and update the docs to recommend using pyright:ignore instead

related issue: #55

the documentation has been updated to mention these issues (#331), i'll leave this issue open until we update enableTypeIgnoreComments to be disabled by default