Python Language Server for the Language Server Protocol
Project description
Python Language Server
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:
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
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:
Code Linting with pycodestyle and pyflakes:
Signature Help:
Go to definition:
Hover:
Find References:
Document Symbols:
Document Formatting:
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
Built Distribution
File details
Details for the file python-language-server-0.36.2.tar.gz
.
File metadata
- Download URL: python-language-server-0.36.2.tar.gz
- Upload date:
- Size: 74.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9984c84a67ee2c5102c8e703215f407fcfa5e62b0ae86c9572d0ada8c4b417b0 |
|
MD5 | b8b7b5aa9de6186c098bddcf8b675a68 |
|
BLAKE2b-256 | 66300c31b052ede62bbeddf4110db57c78d3c704506178caa18b2f0be2271293 |
File details
Details for the file python_language_server-0.36.2-py2.py3-none-any.whl
.
File metadata
- Download URL: python_language_server-0.36.2-py2.py3-none-any.whl
- Upload date:
- Size: 51.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0ad0aca03f4a20c1c40f4f230c6773eac82c9b7cdb026cb09ba10237f4815d5 |
|
MD5 | b7fa56a0b710452f06a45c7f7b415bd6 |
|
BLAKE2b-256 | 9d2785acd3c6dc88bfec5fa14822b88a8d048e13132a0475047950c1aa85ef0d |