Skip to main content

Python Language Server for the Language Server Protocol

Project description

Python Language Server

https://github.com/palantir/python-language-server/workflows/Linux%20tests/badge.svg https://github.com/palantir/python-language-server/workflows/Mac%20tests/badge.svg https://github.com/palantir/python-language-server/workflows/Windows%20tests/badge.svg https://img.shields.io/github/license/palantir/python-language-server.svg

A Python 2.7 and 3.5+ implementation of the Language Server Protocol.

Installation

The base language server requires Jedi to provide Completions, Definitions, Hover, References, Signature Help, and Symbols:

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:

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

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 `

See vscode-client/package.json for the full set of supported configuration options.

Language Server Features

Auto Completion:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/auto-complete.gif

Code Linting with pycodestyle and pyflakes:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/linting.gif

Signature Help:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/signature-help.gif

Go to definition:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/goto-definition.gif

Hover:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/hover.gif

Find References:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/references.gif

Document Symbols:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/document-symbols.gif

Document Formatting:

https://raw.githubusercontent.com/palantir/python-language-server/develop/resources/document-format.gif

Development

To run the test suite:

pip install .[test] && pytest

Develop against VS Code

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

Install VSCode

# 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

License

This project is made available under the MIT License.

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.

Source Distribution

python-language-server-0.36.0.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_language_server-0.36.0-py2.py3-none-any.whl (51.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file python-language-server-0.36.0.tar.gz.

File metadata

  • Download URL: python-language-server-0.36.0.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for python-language-server-0.36.0.tar.gz
Algorithm Hash digest
SHA256 a0fab3c37e3f61e4ee0a721418bf753b66b188a163b3ec04df7efac35599411b
MD5 efeece839725e2b25088298396c553a4
BLAKE2b-256 32fa74ff26d9d4d0e8d39b89560ebb29b63d9747a6837d03f913330aa62dec9e

See more details on using hashes here.

File details

Details for the file python_language_server-0.36.0-py2.py3-none-any.whl.

File metadata

  • Download URL: python_language_server-0.36.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 51.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for python_language_server-0.36.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d8939491ff5af1af2a89d4c3ceb84981e6ca6176ea7f4168ec8eb01ccce60651
MD5 c41deace83e568cb3c1f886973e6d91f
BLAKE2b-256 1b46306da89f080afb3b8345b61401415078dbd10dc63f01cdac8774716bb803

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page