Understanding python.analysis.excludeLibraryDiagnostics in Pylance

June 23, 2026 · View on GitHub

Pylance is a fast and feature-rich language server extension for Python in Visual Studio Code, powered by the Pyright static type checker.

The python.analysis.excludeLibraryDiagnostics setting suppresses diagnostics (errors, warnings, and hints) for library files while continuing to report them for the code you write.

What is python.analysis.excludeLibraryDiagnostics?

When enabled, Pylance does not surface diagnostics for library files — such as the standard library, packages installed in site-packages, and bundled typeshed stubs — but still reports diagnostics for your own user-authored files.

This exists because third-party and standard library code is outside your control. When type checking is enabled, analysis of library code can produce diagnostics that you cannot fix and that distract from issues in your own project. Excluding them keeps the Problems panel focused on actionable findings.

Type: boolean Default: false Scope: resource (can be set per workspace or folder)

How to Change python.analysis.excludeLibraryDiagnostics

Using the Settings UI

  1. Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Preferences: Open Settings (UI).
  2. Search for python.analysis.excludeLibraryDiagnostics.
  3. Check the box to enable it.

Using settings.json

{
    "python.analysis.excludeLibraryDiagnostics": true
}

When to Use It

  • Enable if you use a stricter typeCheckingMode and see diagnostics originating from installed libraries or stubs that you cannot act on.
  • Keep disabled if you want full visibility into analysis of library code, for example when debugging stub-related issues.

See Also


For more information on Pylance settings and customization, refer to the Pylance Settings and Customization documentation.


This document was generated with the assistance of AI and has been reviewed by humans for accuracy and completeness.