Closed pjv closed 3 months ago
you can create a pyproject.toml and put the all that you need inside. like this:
[tool.mypy]
plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"]
strict = true
[tool.django-stubs]
django_settings_module = "api_naiara_joias.settings"
[tool.basedpyright]
venvPath = "../../../.cache/pypoetry/virtualenvs/"
venv = "api-naiara-joias-YxMO4wcW-py3.12"
typeCheckingMode = "basic"
reportOptionalCall = "none"
reportOptionalMemberAccess = "none"
@m1guer please re-read my “Note” in the last paragraph of my original post.
oh, OK!
"lsp": {
"basedpyright": {
"settings": {
"python": {
"pythonPath": ".venv/bin/python"
}
}
},
@m1guer thank you!
Unfortunately, that config is the first thing I tried and it does not work. I have a small test project set up and with the above configuration, basedpyright is not finding the python install in the venv.
Here’s a couple screenshots illustrating the issue.
woocommerce
module has been installed.When I view the same project with pyright using the config from my original post, it does not choke on the import woocommerce
statement.
EDIT: I have also tried this config for basedpyright
with the same results as above:
"lsp": {
"basedpyright": {
"initialization_options": {
"settings": {
"python": {
"pythonPath": ".venv/bin/python"
}
}
}
},
oh in this case you need to use the venvPath instead of pythonPath
oh in this case you need to use the venvPath instead of pythonPath
also does not work.
can share your logs?
2024-08-01T16:10:23.53246Z [INFO] starting language servers for Python: basedpyright, ruff
2024-08-01T16:10:23.532692Z [INFO] starting language server "basedpyright", path: "/Users/pjv/development/test/", id: 119
2024-08-01T16:10:23.532967Z [INFO] starting language server "ruff", path: "/Users/pjv/development/test/", id: 120
2024-08-01T16:10:24.157052Z [INFO] starting language server. binary path: "/usr/local/bin/ruff", working directory: "/Users/pjv/development/test/", args: ["server"]
2024-08-01T16:10:24.265434Z [INFO] starting language server. binary path: "/Users/pjv/.pyenv/shims/basedpyright-langserver", working directory: "/Users/pjv/development/test/", args: ["--stdio", ""]
2024-08-01T16:10:24.793099Z [INFO] Language server with id 119 sent unhandled notification window/logMessage:
{
"type": 3,
"message": "basedpyright language server 1.1.374 starting"
}
2024-08-01T16:10:24.793418Z [INFO] Language server with id 119 sent unhandled notification window/logMessage:
{
"type": 3,
"message": "Server root directory: file:///Users/pjv/.pyenv/versions/3.12.3/lib/python3.12/site-packages/basedpyright/dist"
}
2024-08-01T16:10:24.798941Z [INFO] Language server with id 119 sent unhandled notification window/logMessage:
{
"type": 3,
"message": "Starting service instance \"\""
}
2024-08-01T16:10:24.907395Z [INFO] language server 119: unregistered workspace/DidChangeWatchedFiles capability with id 6e5596e8-0348-4e2a-9ccf-410bd5306176
i dont know why this error is happening, im using poetry for env configs.
maybe some of this articles can help you.
Thanks again. I tried reading all those docs before I posted here.
I might be wrong and I’m very deficient at reading rust code and know nothing at all about Zed’s extension api, but my guess is that the basedpyright extension may need to do something specific to parse and use the initialization_options
object that zed passes to it when the LSP gets instantiated.
Here’s an example of the built-in ruff extension: https://github.com/zed-industries/zed/blob/main/extensions/ruff/src/ruff.rs
I’m thinking that this function might be what is handling the initialization options for the ruff LSP:
thanks, will implement this rn.
@pjv hey i will commit on a diferente brach, can you test locally for me?
I will if you can tell me how to load a development extension build in zed. I’ve only ever installed them through the standard process in zed.
1- clone the repo on your machine. 2- switch to the another branch 3- go to zed 4- uninstall the extension 5- click on install dev extension 6- go to the place where you clone the repo and select the folder.
got it. I cloned and checked out the workspace_intialization_config
and then installed it in Zed and it looks like it’s working.
Thanks for getting it fixed so quick.
your welcome, and thanks for the suggestion. i will open a new PR to update the extension.
Hi,
In my zed
settings.json
, I can configure the pyright initialzation options like this:I have tried every variation on similarly configuring basedpyright but cannot determine a viable syntax for globally configuring basedpyright. Can you show an example like the above that will set up the initialize options for the basedpyright extension?
Note that I am aware that I can create a
pyrightconfig.json
file in my project but that is not the solution I am looking for. I’m trying to find a way to globally configure basedpyright in my zedsettings.json
.