Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type: ignore[...] silences all errors #330

Open
amadanmath opened this issue Apr 30, 2024 · 2 comments
Open

type: ignore[...] silences all errors #330

amadanmath opened this issue Apr 30, 2024 · 2 comments
Labels
config issues relating to config (pyproject.toml, pyrightconfig.json, LSP config or vscode extension) type checking

Comments

@amadanmath
Copy link

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

@amadanmath amadanmath changed the title type; ignore[...] silences all errors type: ignore[...] silences all errors Apr 30, 2024
@DetachHead
Copy link
Owner

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

@DetachHead DetachHead added type checking config issues relating to config (pyproject.toml, pyrightconfig.json, LSP config or vscode extension) labels Apr 30, 2024
@DetachHead
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config issues relating to config (pyproject.toml, pyrightconfig.json, LSP config or vscode extension) type checking
Projects
None yet
Development

No branches or pull requests

2 participants