Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I disable type errors from third-party packages in Pylance?

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?

like image 738
palapapa Avatar asked Nov 23 '25 07:11

palapapa


1 Answers

# 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.

like image 114
Keiji Avatar answered Nov 25 '25 21:11

Keiji