Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Microsoft Language Server for Python

License

Notifications You must be signed in to change notification settings

microsoft/python-language-server

Microsoft Python Language Server

Microsoft Python Language Server implements the Language Server Protocol.

Its primary clients are the Python extension for VS Code and Python Tools for Visual Studio.

Feel free to file issues or ask questions on our issue tracker, and we welcome code contributions.

Build/contributing instructions

See CONTRIBUTING.md

Troubleshooting and known issues

See TROUBLESHOOTING.md.

Linting options (diagnostics)

The language server implements diagnostics (or linting), which runs on user code. The following diagnostics are supported:

CodeDescription
too-many-function-argumentsToo many arguments have been provided to a function call.
too-many-positional-arguments-before-starToo many arguments have been provided before a starred argument.
positional-argument-after-keywordA positional argument has been provided after a keyword argument.
unknown-parameter-nameThe keyword argument name provided is unknown.
parameter-already-specifiedA argument with this name has already been specified.
parameter-missingA required positional argument is missing.
unresolved-importAn import cannot be resolved, and may be missing.
undefined-variableA variable has used that has not yet been defined.

A full list can be seen in the source code.

Linting can be controlled via the user configuration. In VS Code, this is settings.json, but other clients would send this via workspace/didChangeConfiguration.

If python.linting.enabled is set to false in the user configuration, then no diagnostics will be collected other than syntax errors and unresolved imports.

To control the visibility and severity of the diagnotics, there are a number of lists that can be set in the user configuration which make use of each diagnostic's error code.

SettingDescription
python.analysis.errorsDiagnostics which should be shown as errors.
python.analysis.warningsDiagnostics which should be shown as warnings.
python.analysis.informationDiagnostics which should be shown as informational.
python.analysis.disabledDiagnotics which should not be shown at all.

An example of a user configuration which sets these options:

{"python.analysis.errors": ["undefined-variable"], "python.analysis.warnings": ["unknown-parameter-name"], "python.analysis.information": ["unresolved-import"], "python.analysis.disabled": ["too-many-function-arguments", "parameter-missing"], }