Skip to content

Settings.json overridden by Pyrightconfig.json or Pyproject.toml

Luciana Abud edited this page Aug 29, 2024 · 3 revisions

Diagnostic affecting settings

Pylance uses the Pyright type checker as the basis for its diagnostics. There are a number of different settings in Pylance that can be used to configure how Pyright creates diagnostics.

These settings include:

  • python.analysis.autoSearchPaths
  • python.analysis.diagnosticBooleanOverrides
  • python.analysis.diagnosticSeverityOverrides
  • python.analysis.exclude
  • python.analysis.extraPaths
  • python.analysis.ignore
  • python.analysis.include
  • python.analysis.stubPath
  • python.analysis.typeCheckingMode
  • python.analysis.typeshedPaths
  • python.analysis.useLibraryCodeForTypes
  • python.analysis.venvPath

Not overridable

Any of the settings above will show an error in VS Code when a pyrightconfig.json file is present in the workspace:

image

You may be wondering why this is an error. Why can't you override the values in a pyrightconfig.json through VS Code settings?

This is done because the presence of a pyrightconfig.json indicates that a specific folder should be checked in a certain way. It's very similar to the include paths in a C++ make file. Once a pyrightconfig.json is there, all users of that folder should end up with the same set of errors. Without that happening, a user could make a change that doesn't trigger any type errors locally but then when submitted to CI, the pyrightconfig.json would generate different results.

What can be done about it?

If you want to override any of these settings and there's a pyrightconfig.json (or pyproject.toml) present in your workspace, you can edit the config file to update the same setting, or remove the config file.