Config contains unrecognized setting "$schema"
Description
pyrightconfig.json supports JSON schema for ease of editing:
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"typeCheckingMode": "basic",
}
but VSCode basedpyright pops up an error when using that:
(the checker still works, so just a superfluous error)
from my understanding $schema is only meant to be used in json schemas to specify which dialect of JSON Schema the schema was written for, not json files that are validated against a schema.
JSON itself prescribes no behavior at all, so the fact that this overlaps with the field name in JSON Schema is actually irrelevant 🙃
This is one of the "official" ways to set a schema for an arbitrary JSON file in Visual Studio Code.
(a cursory Github code search reveals that it is used quite a bit, 430 results for the exact pyright $schema: ... line in the original issue)
It's also part of the official Python typeshed Pyright test config.
hmm looks like this is a vscode-specific feature:
Note that this syntax is VS Code-specific and not part of the JSON Schema specification. Adding the
$schemakey changes the JSON itself, which systems consuming the JSON might not expect, for example, schema validation might fail. If this is the case, you can use one of the other mapping methods.
i guess it does make sense to support this though. the only reason this works with upstream pyright is because it doesn't report errors on unrecognized settings.
in the mean time, as a workaround you can associate json schemas in .vscode/settings.json:
{
"json.schemas": [
{
"fileMatch": [
"/pyrightconfig.json"
],
"url": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json"
}
]
}