Skip to main content

Python Language Server for the Language Server Protocol

Project description

Python Language Server

.. image::

.. image::

.. image::

A Python 2.7 and 3.4+ implementation of the `Language Server Protocol`_.


The base language server requires Jedi_ to provide Completions, Definitions, Hover, References, Signature Help, and

``pip install python-language-server``

If the respective dependencies are found, the following optional providers will be enabled:

* Rope_ for Completions and renaming
* Pyflakes_ linter to detect various errors
* McCabe_ linter for complexity checking
* pycodestyle_ linter for style checking
* pydocstyle_ linter for docstring style checking (disabled by default)
* autopep8_ for code formatting
* YAPF_ for code formatting (preferred over autopep8)

Optional providers can be installed using the `extras` syntax. To install YAPF_ formatting for example:

``pip install 'python-language-server[yapf]'``

All optional providers can be installed using:

``pip install 'python-language-server[all]'``

If you get an error similar to ``'install_requires' must be a string or list of strings`` then please upgrade setuptools before trying again.

``pip install -U setuptools``

3rd Party Plugins
Installing these plugins will add extra functionality to the language server:

* pyls-mypy_ Mypy type checking for Python 3
* pyls-isort_ Isort import sort code formatting
* pyls-black_ for code formatting using Black_

Please see the above repositories for examples on how to write plugins for the Python Language Server. Please file an
issue if you require assistance writing a plugin.


Configuration is loaded from zero or more configuration sources. Currently implemented are:

* pycodestyle: discovered in ~/.config/pycodestyle, setup.cfg, tox.ini and pycodestyle.cfg.
* flake8: discovered in ~/.config/flake8, setup.cfg, tox.ini and flake8.cfg

The default configuration source is pycodestyle. Change the `pyls.configurationSources` setting to `['flake8']` in
order to respect flake8 configuration instead.

Overall configuration is computed first from user configuration (in home directory), overridden by configuration
passed in by the language client, and then overriden by configuration discovered in the workspace.

To enable pydocstyle for linting docstrings add the following setting in your LSP configuration:
"pyls.plugins.pydocstyle.enabled": true

Language Server Features

Auto Completion:

.. image::

Code Linting with pycodestyle and pyflakes:

.. image::

Signature Help:

.. image::

Go to definition:

.. image::


.. image::

Find References:

.. image::

Document Symbols:

.. image::

Document Formatting:

.. image::


To run the test suite:

``pip install .[test] && tox``

Develop against VS Code

The Python language server can be developed against a local instance of Visual Studio Code.

1. Install `VSCode <`_

.. code-block:: bash

# Setup a virtual env
virtualenv env
. env/bin/activate

# Install pyls
pip install .

# Install the vscode-client extension
cd vscode-client
yarn install

# Run VSCode which is configured to use pyls
# See the bottom of vscode-client/src/extension.ts for info
yarn run vscode -- $PWD/../

Then to debug, click View -> Output and in the dropdown will be pyls.
To refresh VSCode, press `Cmd + r`


This project is made available under the MIT License.

.. _Language Server Protocol:
.. _Jedi:
.. _Rope:
.. _Pyflakes:
.. _McCabe:
.. _pycodestyle:
.. _pydocstyle:
.. _YAPF:
.. _autopep8:
.. _pyls-mypy:
.. _pyls-isort:
.. _pyls-black:
.. _Black:

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-language-server, version 0.26.1
Filename, size File type Python version Upload date Hashes
Filename, size python-language-server-0.26.1.tar.gz (55.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page