Skip to content
Microsoft Language Server for Python
C# Python
Branch: master
Clone or download
AlexanderSher and MikhailArkhipov - Fix #1455: AF: Library module of type Stub has been analyzed alread…
…y! (#1470)

- Restore task handling in unit tests
- Throw exception from Debug.Fail instead of FailFast
Latest commit 870361c Aug 22, 2019

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


Troubleshooting and known issues


Linting options (diagnostics)

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

Code Description
inherit-non-class Attempted to inherit something that is not a class.
too-many-function-arguments Too many arguments have been provided to a function call.
too-many-positional-arguments-before-star Too many arguments have been provided before a starred argument.
parameter-already-specified A argument with this name has already been specified.
parameter-missing A required positional argument is missing.
positional-argument-after-keyword A positional argument has been provided after a keyword argument.
return-in-init Encountered an explicit return in __init__ function.
typing-generic-arguments An error occurred while constructing Generic.
typing-typevar-arguments An error occurred while constructing TypeVar.
typing-newtype-arguments An error occurred while constructing NewType.
unknown-parameter-name The keyword argument name provided is unknown.
unresolved-import An import cannot be resolved, and may be missing.
undefined-variable A variable has been used that has not yet been defined.
variable-not-defined-globally A variable is not defined in the global scope.
variable-not-defined-nonlocal A variable is not defined in non-local scopes.

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.

Setting Description
python.analysis.errors Diagnostics which should be shown as errors.
python.analysis.warnings Diagnostics which should be shown as warnings.
python.analysis.information Diagnostics which should be shown as informational.
python.analysis.disabled Diagnotics 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"],

Linting can also be controlled on an invidual line basis with a generalized #noqa. Lines with #noqa will have their diagnostic output suppressed.

An example usage:

from python import language_server  # noqa will suppress the linting message for this line
You can’t perform that action at this time.