Package: python-lsp-pyre
python-lsp-pyreThis is a plugin for thePython LSP Server.It implements support for calling Meta'sPyre type checkervia 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.FeaturesThis plugin adds the following features topython-lsp-server:Type linting via Meta's Pyre (pyre-check)InstallationTo use this plugin, you need to install this plugin in the same virtualenv aspython-lsp-serveritself.pipinstallpython-lsp-pyreor to make it a development requirement in Poetrypoetryadd-Gdevpython-lsp-pyreThen runpython-lsp-serveras usual, the plugin will be auto-discovered bypython-lsp-serverif you've installed it to the right environment. Refer topython-lsp-serverand your IDE/text editor documentation on how to setuppython-lsp-server. The plugin's defaultenabledstatus isTrue.Editor integrationAn example is provided for KDE'sKate editorConfigurationMeta's Pyre uses.pyre_configurationfiles in your project to set up lint controls. It does not readpyproject.toml.On first run of this plugin, it will detect a missing.pyre_configurationand write out one for you if thecreate-pyre-configconfigurationoption is enabled. It relies on the workspace root passed to the language server for this write. This file is not immutable, and thereference documentationmay be useful.You can also usepyre initinstead 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 frompyre initis 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_configurationfile 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 errorsThe recommended way of squelching a Pyre warning is to pick one of# pyre-ignoreor# pyre-fixme. More precisely, suppose Pyre is indicatingMissing 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 workto 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 thetype errors documentation.When you address the squelched error, Pyre will indicate that the comment is not suppressing a type error and can be removed.DevelopingInstall development dependencies with (you might want to create a virtualenv first):gitclonehttps://github.com/cricalix/python-lsp-pyrepython-lsp-pyrecdpython-lsp-pyre
pipinstall-e'.[dev]'Alterately, if you use Poetry,gitclonehttps://github.com/cricalix/python-lsp-pyrepython-lsp-pyrecdpython-lsp-pyre
poetryinstallwill set up a virtualenv if necessary, install all dependencies, and then install this project in editable/development mode.ContributingThis 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.