Closed DMunkei closed 1 month ago
this is probably because basedpyright enables all diagnostic rules by default (my reasoning behind this decision is explained here).
if you want the same defaults as pyright, you can set typeCheckingMode
to "standard"
:
# pyproject.toml
[tool.basedpyright]
typeCheckingMode = "standard"
more info about the configuration is available here
I also thought that this might be the case since it's set to all
per default. I've changed it to standard
inside of my lsp.lua
file where I can set other options. The effect was still the same.
I had a slight error in my config. The pyright
configuration inside of Mason
has the setting key under python
.
The basedpyright configuration has the settings key under basedpyright
. So I was using the incorrect key to configure basedpyright from within my lsp.lua
file.
Here's the excerpt from the Mason lsp documentation.
Pyright
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
useLibraryCodeForTypes = true
}
}
basedpyright
basedpyright = { <--- This was my mistake, had python instead
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
useLibraryCodeForTypes = true
}
}
Setting the typeCheckingMode = "standard"
has the same output as the pyright
standard
setting. Vice-versa, if you set pyright
to strict
it shows the same errors as basedpyright
.
It's working as intended now.
I've got a Django project that makes use of the Django RESTFramework and Django version
4.2
.In order to help my editor
NeoVim
to get the proper typing, I've installed the type stubs:Now when I am inside of a
models.py
file and declare my model class I am gettingI've also tried running both
pyright
andbasedpyright
directly from the terminal on the exact same file as above. And the outputs are as follows.I have also made sure that I am already running my virtual environment before executing the command to make sure that the type stubs are collected.
This is only reported when I have basedpyright running. Inside of the same exact file pyright doesn't seem to have an issue with it.
I stumbled upon basedpyright by chance and have to say, it's definetly cooler when it comes to the additional information it's providing the editor. And would like to keep using it :D.
Any idea why this might be the case?
I'm happy to provide additional information if necessary. Thanks :)