-
|
Hi, I don't manage to make pyright see For example, if I have I've installed pyright in a python virtual env using pip. At the root directory of my project, I launch nvim after my venv has been activated Below :
I'm confused because python doc states :
... and Pycharm IDE understands this configuration by default. Also the numpy codebase seems to use this stubfiles arrangement. What am I missing ? Do I understand things correctly ?
-- see : https://github.com/neovim/nvim-lspconfig/blob/master/lsp/pyright.lua
return {
-- pyright is installed in a python venv, nvim must be launched after the correct venv has been activated
cmd = { "pyright-langserver", "--stdio" },
filetypes = { "python" },
root_markers = {
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
".git",
},
settings = {
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
useLibraryCodeForTypes = true,
},
},
},
}
{
"typeCheckingMode" : "strict",
"python" : {
"pythonPath" : "<path_to_my_venv_folder>/bin/python",
},
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
You're not using stub files correctly here. A stub file is a stand-in for a ".py" file in cases where the ".py" file is unannotated or the implementation is in a language other than Python. A stub file is used by a type checker when the module is imported. For example, if you have a stub file named If your intent is to type check |
Beta Was this translation helpful? Give feedback.
There are two scenarios here:
Scenario 1: You want to type check a codebase that imports symbols from the
toy-packagelibrary, but thetoy-packagelibrary is either written in a language other than Python or is written in untyped Python. Stub files are designed for this scenario. You can create stub files and include them either within toy-package or as a separate "stub library". Consumers oftoy-packagecan then benefit from type checking when they import symbols from the library. When a type checker sees a import statement likefrom toy_package.foo import bar, it will look for atoy_package/foo.pyistub file before looking for atoy_package/foo.pyfile. If the stub file exists, it will …