Skip to main content

python-lsp-pyre

This is a plugin for the Python LSP Server.

It implements support for calling Meta's Pyre type checker via a subprocess.

Pyre does offer a language server of its own, and that may be more useful to you if your editor supports multiple language servers per language.

Features

This plugin adds the following features to python-lsp-server:

  • Type linting via Meta's Pyre (pyre-check)

Installation

To use this plugin, you need to install this plugin in the same virtualenv as python-lsp-server itself.

pip install python-lsp-pyre

or to make it a development requirement in Poetry

poetry add -G dev python-lsp-pyre

Then run python-lsp-server as usual, the plugin will be auto-discovered by python-lsp-server if you've installed it to the right environment. Refer to python-lsp-server and your IDE/text editor documentation on how to setup python-lsp-server. The plugin's default enabled status is True.

Editor integration

Configuration

Meta's Pyre uses .pyre_configuration files in your project to set up lint controls. It does not read pyproject.toml.

On first run of this plugin, it will detect a missing .pyre_configuration and write out one for you if the create-pyre-config configuration option is enabled. It relies on the workspace root passed to the language server for this write. This file is not immutable, and the reference documentation may be useful.

You can also use pyre init instead to set up the configuration.

The configuration written by this plugin is:

{
    "site_package_search_strategy": "all",
    "source_directories": [
        "."
    ],
    "exclude": [
        "/setup.py",
        ".*/build/.*"
    ],
    "strict": true
}

The noteable difference from pyre init is the change to the search strategy ("pep561" to "all"), and turning on strict mode as the default. You may find strict mode a bit pedantic, but having worked with strict mode for several years, I highly recommend it.

If the .pyre_configuration file is not present (or has a syntax error), the LSP error log, LSP output, and your editor's LSP messages will display an ABEND message containing the error from Pyre as it fails to run.

Squelching Pyre lint errors

The recommended way of squelching a Pyre warning is to pick one of # pyre-ignore or # pyre-fixme. More precisely, suppose Pyre is indicating

Missing global annotation [5]: Globally accessible variable `logger` has type `logging.Logger` but no type is specified.

at you, and you do not feel like typing your logger right now. On the line before, you can put either one of

  • # pyre-ignore[5] Don't care about logger
  • # pyre-fixme[5] Resolve this when doing all logger work

to squelch the lint, and provide a hint to future you (or other readers of the code). This is a trivial example; it's easier to just type the logger.

You do not need to match the number in the brackets, other than for ease of cross-reference with the type errors documentation.

When you address the squelched error, Pyre will indicate that the comment is not suppressing a type error and can be removed.

Developing

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

git clone https://github.com/cricalix/python-lsp-pyre python-lsp-pyre
cd python-lsp-pyre
pip install -e '.[dev]'

Alterately, if you use Poetry,

git clone https://github.com/cricalix/python-lsp-pyre python-lsp-pyre
cd python-lsp-pyre
poetry install

will set up a virtualenv if necessary, install all dependencies, and then install this project in editable/development mode.

Contributing

This plugin was written to scratch an itch. If you find it useful, great!

If something about it annoys you, or you think there's a better way to do something, you're welcome to send a PR.

Metadata

Release files for python-lsp-pyre 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-lsp-pyre 0.1.3
File Size Uploaded Provenance Actions
python_lsp_pyre-0.1.3.tar.gz 5.0 kB Without provenance Details for python_lsp_pyre-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-lsp-pyre 0.1.3
File Interpreter ABI Platform Actions
python_lsp_pyre-0.1.3-py3-none-any.whl Python 3 none any Details for python_lsp_pyre-0.1.3-py3-none-any.whl

Total release size: 10.7 kB

Release files / python_lsp_pyre-0.1.3.tar.gz

Download URL python_lsp_pyre-0.1.3.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
16907a8ac7f161751e9cd51bdcf89c3482000fb09bf3647277076a1c84ab06c3
BLAKE2b-256 checksum
How to use checksums
8f07012a4fcc1c6e28695610e13b9f058feb854f575c0cfb075255d852926446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / python_lsp_pyre-0.1.3-py3-none-any.whl

Download URL python_lsp_pyre-0.1.3-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5d62be6e85a8afa30a57676375018d938662fb50ac1f99667ad29958fe1bdbf
BLAKE2b-256 checksum
How to use checksums
ca8645be6bc9e61e54880f092ce75846634320c1cb13274ad67369ee0596169e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Security for python-lsp-pyre 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page