sublimelsp / LSP-pyright

Python support for Sublime's LSP plugin provided through microsoft/pyright.
MIT License
131 stars 13 forks source link

Settings python.analysis.extraPaths Conflict with pyrightconfig extraPaths #241

Closed munkybutt closed 1 year ago

munkybutt commented 1 year ago

Hey - I am trying to add paths to my .sublime-project file using "python.analysis.extraPaths". This is used to add project specific paths on top of the paths in my pyrightconfig.json file. The pyrightconfig.json is used to define shared settings for a number of projects that have the same set of dependencies as well as sharing pyright settings with vscode projects. It seems that project settings are ignored if the pyrightconfig.json file already has "extraPaths" defined:

"settings":
{
    "LSP": {
        "LSP-pyright": {
            "settings": {
                "python.analysis.extraPaths": [
                    // paths here
                ]
            }
        }
    }
}

This is the same behaviour if I define "python.analysis.extraPaths" in the LSP-pyright global settings, pyrightconfig.json takes precedence.

If this is intentional is it possible to update the behaviour to be additive rather than exclusive?

jfcherng commented 1 year ago

I am not convinced that this is an issue of LSP-pyright. LSP-* merges project settings with plugin settings and send it to the server. That's all. This should be in https://github.com/microsoft/pyright/issues.

In https://github.com/microsoft/pyright/blob/main/docs/configuration.md, it only mentions A “pyrightconfig.json” file always takes precedent over “pyproject.toml” if both are present..

and there are 4 potential configuration sources:

It's only obvious that “pyrightconfig.json” overrides “pyproject.toml”.

munkybutt commented 1 year ago

If I replicate this setup in VSCode ( pyrightConfig.json with "extraPaths" defined and then define "python.analysis.extraPaths" in the .workspace file ) the behaviour is that the two lists are merged - which is the behaviour I was expecting with Sublime 😢

jfcherng commented 1 year ago

I don't see extraPaths in pyrightconfig.json is sent to Pylance in VSCode, which means it's likely handled by the server itself, which makes sense. That says, I can't reproduce your claim.


Update:

Pretty sure lists are not merged. pyrightconfig.json is prioritized and overrides workspace config.

https://user-images.githubusercontent.com/6594915/234612349-2d9ae9d6-a664-4b78-ad5b-1d08bec9cac9.mp4

jfcherng commented 1 year ago

Closed as I think this issue belongs to pyright (though I don't think they will change this behavior).