4

I am using pyright type checker and need to suppress warnings where e.g. numpy type stubs are insufficient to infer correct types. This can be accomplished with #type: ignore comment. However, I'd like any other issue to still be highlighted on the same line. For example mypy offers show_error_codes option that gives error codes that I can append to type:ignore comment to have only this specific issue suppressed.

I couldn't find such option in the docs https://github.com/microsoft/pyright/blob/main/docs/configuration.md . Is it possible to have specific error codes shown / ignored with pyright?

Boschie
  • 467
  • 3
  • 13

1 Answers1

4

I just found out how to do that in both Pyright and Pylance.

When you run pyright it should give a detailed error report and show the corresponding diagnostic type, such as reportOptionalMemberAccess or reportOptionalSubscript. Same can be achieved by looking through the diagnostics reported by the language server (LSP).

You can then annotate the line with # pyright: ignore[reportOptionalMemberAccess] to disable this type of diagnostic.

disrupted
  • 41
  • 3