11

Some of the packages I use don't type hint their code, so when I use them, Pylance keeps telling me that the functions I use have partially unknown types, which is a problem I can't fix. Is there a way to disable such errors?

Alex Waygood
  • 6,304
  • 3
  • 24
  • 46
palapapa
  • 573
  • 2
  • 5
  • 25

1 Answers1

0
# type: ignore

Place this comment at the top of a file to ignore all type-checking errors in the file.

Similarly, place it at the end of a line to just ignore errors on that line.

When I come across a third-party package that doesn't provide typing information, I generally make a wrapper for it, in a file on its own, and use that wrapper from the rest of my codebase - this allows me to just use the per-file ignore, while minimising the amount of code that has to have type-checking disabled.

Keiji
  • 880
  • 5
  • 12