CC
ccordoba12/python-lsp-black
python-lsp-server plugin that adds support to black autoformatter, forked from https://github.com/rupert/pyls-black/
python-lsp-black
Black plugin for the Python LSP Server.
Install
In the same virtualenv as python-lsp-server:
pip install python-lsp-blackUsage
To avoid unexpected results you should make sure yapf and autopep8 are not installed.
python-lsp-blackcan either format an entire file or just the selected text.- The code will only be formatted if it is syntactically valid Python.
- Text selections are treated as if they were a separate Python file.
Unfortunately this means you can't format an indented block of code. python-lsp-blackwill use your project's pyproject.toml if it has one.
Development
To install the project for development you need to specify the dev optional dependencies:
python -m venv .venv
. .venv/bin/activate
pip install -e .[dev]This project uses pre-commit hooks to control code quality,
install them to run them when creating a git commit, thus avoiding seeing errors when you
create a pull request:
pre-commit installTo run tests:
make testTo run linters:
make lint # just a shortcut to pre-commit run -a
make <linter_name> # black, flake8, isort, mypyTo upgrade the version of the pre-commit hooks:
pre-commit autoupdate
# check and git commit changes to .pre-commit-config.yaml