Mypy linter for the Python LSP Server
Project description
# Mypy plugin for PYLSP
[](https://badge.fury.io/py/pylsp-mypy) [](https://github.com/python-lsp/pylsp-mypy) [](https://github.com/pre-commit/pre-commit)
This is a plugin for the [Python LSP Server](https://github.com/python-lsp/python-lsp-server), to make [mypy](https://github.com/python/mypy) output available directly in your IDE. pylsp-mypy uses [mypy](https://github.com/python/mypy) to help you write statically typed Python code. It, like [mypy](https://github.com/python/mypy), requires Python 3.10 or newer.
## Installation
Install into the same virtualenv as python-lsp-server itself.
`bash pip install pylsp-mypy `
## Configuration
pylsp-mypy supports the use of pyproject.toml for configuration. This is the recommended way.
For more advanced usecases, it can also be configuered using configs provided directly to the LSP server. To use this prepend pylsp.plugins.pylsp_mypy. to any configuration key. For example strict becomes pylsp.plugins.pylsp_mypy.strict
The configuration keys are listed in the following.
Both mypy_command and dmypy_command could be used by a malicious repo to execute arbitrary code by looking at its source with this plugin active. Still users want this feature. For security reasons this is disabled by default. If you really want it and accept the risks, set the environment variable PYLSP_MYPY_ALLOW_DANGEROUS_CODE_EXECUTION in order to activate it.
Using a pyproject.toml for configuration, which is in fact the preferred way, your configuration could look like this:
`toml [tool.pylsp-mypy] enabled = true live_mode = true strict = true exclude = ["tests/*"] `
It should be roughly like this for a standard configuration:
`toml [tool.pylsp-mypy] enabled = true live_mode = true strict = false exclude = ["tests/*"] `
With dmypy enabled your config should look like this:
`toml [tool.pylsp-mypy] enabled = true live_mode = false dmypy = true strict = false `
With overrides specified (for example to tell mypy to use a different python than the currently active venv), your config could look like this:
`toml [tool.pylsp-mypy] enabled = true overrides = ["--python-executable", "/home/me/bin/python", true] `
With dmypy_status_file your config could look like this:
`toml [tool.pylsp-mypy] enabled = true live_mode = false dmypy = true strict = false dmypy_status_file = ".custom_dmypy_status_file.json" `
With config_sub_paths your config could look like this:
`toml [tool.pylsp-mypy] enabled = true config_sub_paths = [".config"] `
With report_progress your config could look like this:
`toml [tool.pylsp-mypy] enabled = true report_progress = true `
With mypy_command your config could look like this:
`toml [tool.pylsp-mypy] enabled = true mypy_command = ["poetry", "run", "mypy"] `
With dmypy_command your config could look like this:
`toml [tool.pylsp-mypy] enabled = true live_mode = false dmypy = true dmypy_command = ["/path/to/venv/bin/dmypy"] `
## Developing
Install development dependencies with (you might want to create a virtualenv first):
`bash pip install -r requirements.txt `
The project is formatted with [black](https://github.com/psf/black). You can either configure your IDE to automatically format code with it, run it manually (black .) or rely on pre-commit (see below) to format files on git commit.
The project is formatted with [isort](https://github.com/PyCQA/isort). You can either configure your IDE to automatically sort imports with it, run it manually (isort .) or rely on pre-commit (see below) to sort files on git commit.
The project uses a markdown test in order to assure uploadability to pypi: [markdownlint](https://github.com/DavidAnson/markdownlint-cli2) as a pre-commit hook and in a GitHub workflow. This does not catch all errors.
This project uses [pre-commit](https://pre-commit.com/) to enforce code-quality. After cloning the repository install the pre-commit hooks with:
`bash pre-commit install `
After that pre-commit will run [all defined hooks](.pre-commit-config.yaml) on every git commit and keep you from committing if there are any errors.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylsp_mypy-0.7.2.tar.gz.
File metadata
- Download URL: pylsp_mypy-0.7.2.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efcf7151b5a4773640bbc48169eaafeb8c55b21f60d750056d375db2258d36fc
|
|
| MD5 |
f1b7601c9700315df51df91ce67be205
|
|
| BLAKE2b-256 |
828d6b0e7878e6791a9a564316704fe7edd2281120d17d2cbb21715125085c07
|
File details
Details for the file pylsp_mypy-0.7.2-py3-none-any.whl.
File metadata
- Download URL: pylsp_mypy-0.7.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c862b038c513f3646700f098e059af93cc8d553339881b4b8ad4ddf85e62c49
|
|
| MD5 |
fbc7577ddeb9907aedbcccb19aa5ff79
|
|
| BLAKE2b-256 |
3e44fcaa0b60749110ae8346ece0fac4601063c673da03cd5db9ceb2964d7b95
|