Pyrefly in the IDE
Pyrefly seamlessly integrates into IDEs with our VSCode and OpenVSX extensions. For other editors like vim/emacs, see other editors.
Quick start
- Install the Pyrefly extension from the VSCode marketplace or OpenVSX
- Open a python file and the extension will activate
Features
The Pyrefly extension provides:
- Inline type errors matching the Pyrefly command-line
- Types shown inline and on hover
- Go-to definition
- Autocomplete / intellisense
- Basic document symbols / breadcrumbs
- Find references
Customization
By default, Pyrefly should work in the IDE with no configuration necessary. But to ensure your project is set up properly, see configurations.
The following configuration options are IDE-specific and exposed as VSCode settings:
python.pyrefly.disableLanguageServices
[boolean: false]: by default, Pyrefly will provide both type errors and other language features like go-to definition, intellisense, hover, etc. Enable this option to keep type errors from Pyrefly unchanged but use VSCode's Python extension for everything else.python.pyrefly.disableTypeErrors
[boolean: false]: by default, Pyrefly will provide type errors in your project. Enable this setting to disable type error squiggles appearing in the editor.
If the project configuration does not specify the Python interpreter, Pyrefly will use the interpreter selected in VSCode.
Issues?
If you experience issues with the Pyrefly extension, please create an issue on github.
Other Editors
Support for other editors is community-driven. If you would like to set this up, please contribute.
Jetbrains
An unofficial Jetbrains extension has been developed here
Neovim + lspconfig
With the lspconfig
plugin and uv
installed, you can use this configuration:
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.pyrefly then
configs.pyrefly = {
cmd = { "uv", "run", "pyrefly", "lsp" },
filetypes = { "python" },
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname) or vim.loop.os_homedir()
end,
settings = {},
},
end
lspconfig.pyrefly.setup({})
Neovim 0.11+
Place the following file under ~/.config/nvim/lsp
return {
cmd = { "pyrefly", "lsp" },
filetypes = { "python" },
settings = {},
on_exit = function(code, _, _)
vim.notify("Closing Pyrefly LSP exited with code: " .. code, vim.log.levels.INFO)
end,
}
Then enable it in init.lua
:
vim.lsp.enable({"pyrefly"})
Vim + Ale
Once this gets merged, you will only need:
let g:ale_linters = {
...
\ 'python': ['pyrefly'],
...
\ }