You can include additional Python
source paths with lsp-pyright-extra-paths
. Here is my pyrightconfig.json
for a project.
{
"exclude": ["**/node_modules", "**/__pycache__"],
"ignore": ["**/node_modules", "**/__pycache__"],
"include": ["flextensor", "tvm"]
"pythonPlatform": "Linux",
"pythonVersion": "3.6",
"reportMissingImports": true,
"reportMissingTypeStubs": false,
"stubPath": "typings",
"typeCheckingMode": "basic",
"venvPath": "/home/swarnendu/tmp/virtualenvs",
"venv": "flextensor-venv"
}
Here is my Emacs setup (init.el
) for pyright
(ignoring remote Tramp setup). You could also use use-package
for this.
(when (executable-find "pyright")
(unless (fboundp 'lsp-pyright-locate-python)
(autoload #'lsp-pyright-locate-python "lsp-pyright" nil t))
(unless (fboundp 'lsp-pyright-locate-venv)
(autoload #'lsp-pyright-locate-venv "lsp-pyright" nil t))
(add-hook 'python-mode-hook (lambda ()
(require 'lsp-pyright)
(lsp-deferred)))
(defvar lsp-pyright-python-executable-cmd)
(setq lsp-pyright-python-executable-cmd "python3")))
Here is the .dir-locals.el
for the same project.
(
(python-mode . (
(pyvenv-activate . "/home/swarnendu/tmp/virtualenvs/flextensor-venv")
(eval . (let (
(paths
(vconcat (list
(expand-file-name "flextensor" (projectile-project-root))
(expand-file-name "tvm" (projectile-project-root))
))))
(setq lsp-pyright-extra-paths paths)))
))
)
Please check whether a similar setup works for you.