Skip to main content

Mypy linter for the Python LSP Server

Project description

https://badge.fury.io/py/pylsp-mypy.svg https://github.com/python-lsp/pylsp-mypy/workflows/Python%20package/badge.svg?branch=master

This is a plugin for the Python LSP Server.

It, like mypy, requires Python 3.7 or newer.

Installation

Install into the same virtualenv as python-lsp-server itself.

pip install pylsp-mypy

Configuration

live_mode (default is True) provides type checking as you type.

This writes to a tempfile every time a check is done. Turning off live_mode means you must save your changes for mypy diagnostics to update correctly.

dmypy (default is False) executes via dmypy run rather than mypy.

This uses the dmypy daemon and may dramatically improve the responsiveness of the pylsp server, however this currently does not work in live_mode. Enabling this disables live_mode, even for conflicting configs.

strict (default is False) refers to the strict option of mypy.

This option often is too strict to be useful.

overrides (default is [True]) specifies a list of alternate or supplemental command-line options.

This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run. When present, the special boolean member True is replaced with the command-line options that would’ve been passed had overrides not been specified. Later options take precedence, which allows for replacing or negating individual default options (see mypy.main:process_options and mypy --help | grep inverse).

This project supports the use of pyproject.toml for configuration. It is in fact the preferred way. Using that your configuration could look like this:

[tool.pylsp-mypy]
enabled = true
live_mode = true
strict = true

A pyproject.toml does not conflict with the legacy config file given that it does not contain a pylsp-mypy section. The following explanation uses the syntax of the legacy config file. However, all these options also apply to the pyproject.toml configuration (note the lowercase bools). Depending on your editor, the configuration (found in a file called pylsp-mypy.cfg in your workspace or a parent directory) should be roughly like this for a standard configuration:

{
    "enabled": True,
    "live_mode": True,
    "strict": False
}

With dmypy enabled your config should look like this:

{
    "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:

{
    "enabled": True,
    "overrides": ["--python-executable", "/home/me/bin/python", True]
}

Developing

Install development dependencies with (you might want to create a virtualenv first):

pip install -r requirements.txt

The project is formatted with 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. 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 two rst tests in order to assure uploadability to pypi: rst-linter as a pre-commit hook and rstcheck in a GitHub workflow. This does not catch all errors.

This project uses pre-commit to enforce code-quality. After cloning the repository install the pre-commit hooks with:

pre-commit install

After that pre-commit will run all defined hooks on every git commit and keep you from committing if there are any errors.

Project details


Download files

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

Source Distribution

pylsp-mypy-0.6.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

pylsp_mypy-0.6.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pylsp-mypy-0.6.2.tar.gz.

File metadata

  • Download URL: pylsp-mypy-0.6.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pylsp-mypy-0.6.2.tar.gz
Algorithm Hash digest
SHA256 e709a244eb56768765f334de550bd9101d2312fa2a6dd077c7bbf939b7b3fba1
MD5 25812b988f81dec5eae2014e7b6814eb
BLAKE2b-256 1260d880c0321b49d65fd58739b008a3a94a83adc27f08866196453c00508128

See more details on using hashes here.

File details

Details for the file pylsp_mypy-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: pylsp_mypy-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pylsp_mypy-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 473bf16027c3a69d8052c184ba72f049ce137b10eeefea0b1414c9e589ec79a9
MD5 9e15b91d56e8ab765c580a39f734a307
BLAKE2b-256 d105de5fa07f701a5024722ac33736756e066b9f9af6432ae74106ecd2a30307

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