pythonpython-typingpyright

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?


Solution

  • Pylance uses Pyright for type checking, so you can configure Pyright to ignore type errors from specific third-party packages. To do this, create a pyrightconfig.json file with the following content (for example, to exclude matplotlib):

    {
      "exclude": [
        "**/site-packages/matplotlib/**"
      ]
    }
    

    This will prevent Pyright from analyzing matplotlib, effectively suppressing type-related warnings from that package. You can add other packages to the exclude list as needed.