Understanding python.analysis.diagnosticMode in Pylance

April 8, 2026 · View on GitHub

Pylance is a fast, feature-rich language support extension for Python in Visual Studio Code, powered by the Pyright static type checker. It provides type checking, completions, navigation, and diagnostics that help you spot problems while you work.

The python.analysis.diagnosticMode setting controls how broadly Pylance analyzes your workspace when producing diagnostics.

What python.analysis.diagnosticMode does

python.analysis.diagnosticMode tells Pylance whether diagnostics should be produced only for files you currently have open or for all files in the workspace.

The default value is openFilesOnly.

"python.analysis.diagnosticMode": "openFilesOnly"

Accepted values

  • openFilesOnly
    • Analyze and report diagnostics for open files only.
    • This is the default.
  • workspace
    • Analyze and report diagnostics for all files in the workspace.

When to use each value

Use openFilesOnly when you want a lighter default workflow

openFilesOnly is usually the right choice when:

  • you work in a large repository and want to reduce ongoing diagnostic work
  • you care primarily about diagnostics in the files you are actively editing
  • workspace-wide diagnostics would be noisy or expensive

This mode is commonly the better fit for very large workspaces, monorepos, or course/exercise folders where you do not need every file checked all the time.

Use workspace when you want full-project diagnostics

workspace is useful when:

  • you want errors surfaced in unopened files
  • you treat the editor as a project-wide diagnostic pass, not just an active-file tool
  • you are working in a smaller or more tightly managed workspace

What this setting does not do

python.analysis.diagnosticMode controls diagnostic scope. It does not redefine the workspace itself.

That distinction matters in large workspaces. Even with openFilesOnly, Pylance may still perform workspace-related setup or feature work that is separate from reporting diagnostics for every file.

If your goal is to reduce how much content belongs to the workspace in the first place, use these settings alongside diagnosticMode:

In other words:

  • use diagnosticMode to decide how broadly diagnostics are reported
  • use include and exclude to shape the workspace contents
  • use ignore when you still want files processed but do not want diagnostics from them

Performance considerations

Switching from workspace to openFilesOnly can reduce diagnostic workload in large repositories.

However, if performance problems come from the size or shape of the workspace itself, diagnosticMode may not be the only setting you need to adjust. In that case, narrowing python.analysis.include or broadening python.analysis.exclude is often more effective.

For example, if you want Pylance to avoid most workspace files entirely, excluding large generated folders, vendored code, or exercise archives may help more than changing diagnostic scope alone.

If you are tuning Pylance for overall performance, these are the other settings worth checking alongside diagnosticMode:

Those settings do different jobs, but together they form the main performance-sensitive surface area for large workspaces.

Example configurations

Open files only

{
    "python.analysis.diagnosticMode": "openFilesOnly"
}

Full workspace diagnostics

{
    "python.analysis.diagnosticMode": "workspace"
}

Open-file diagnostics with an aggressively narrowed workspace

{
    "python.analysis.diagnosticMode": "openFilesOnly",
    "python.analysis.exclude": ["**/build/**", "**/generated/**", "**/.venv/**"]
}

Frequently asked questions

Why does Pylance still seem busy when diagnosticMode is openFilesOnly?

Because openFilesOnly limits diagnostic reporting scope, not every kind of workspace-related work. If the workspace is very large, consider adjusting python.analysis.include or python.analysis.exclude as well.

Does openFilesOnly mean unopened files are never considered for anything?

No. It means diagnostics are reported only for open files. Other language-service behavior can still depend on workspace structure and project configuration.

Should I use ignore instead of diagnosticMode?

Not usually. Use diagnosticMode when you want to control analysis scope globally. Use python.analysis.ignore when you want to suppress diagnostics only for specific paths.

diagnosticMode controls whether diagnostics appear for all workspace files or only open ones. It does not affect which rules are enabled — that is controlled by typeCheckingMode and diagnosticSeverityOverrides.

If diagnostics are missing for specific files, see How to Troubleshoot Settings: Diagnostics Missing for Some Files.

See Also


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