sublimelsp / LSP-pyright

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

How to add the current project path to "python.analysis.extraPaths", currently using version 1.3.1 #324

Open maryjeck opened 4 months ago

maryjeck commented 4 months ago

before the version 1.3.1,it's auto include it

jfcherng commented 4 months ago

We do have some logics for python.analysis.extraPaths but I don't think LSP-pyright have ever included the current project path. What we do for python.analysis.extraPaths is to find Sublime Text API stubs and installed Python libraries for Sublime Text plugin hosts and that only happens when the user sets pyright.dev_environment. That's totally unrelated to your description.

jfcherng commented 4 months ago

Since your description is pretty specific, how do you find LSP-pyright adds the current project path to python.analysis.extraPaths? Or, maybe, what you are actually trying to achieve?

jfcherng commented 4 months ago

Didn't see Path (plaintext search) in pyright's recent changelog either 🤔

maryjeck commented 4 months ago

In the previous version, my custom module could be imported normally, but in this latest version, my project's custom module cannot be recognized. So I want to ask if there is any special parameter indicating the current project path

jfcherng commented 4 months ago

In the previous version, my custom module could be imported normally, but in this latest version, my project's custom module cannot be recognized. So I want to ask if there is any special parameter indicating the current project path

Could you provide a minimal reproducer repository (or uploading a .zip file) for test?

maryjeck commented 4 months ago

In the previous version, my custom module could be imported normally, but in this latest version, my project's custom module cannot be recognized. So I want to ask if there is any special parameter indicating the current project path在以前的版本中,我的自定义模块可以正常导入,但在这个最新版本中,我无法识别我的项目的自定义模块。所以我想问一下是否有任何特殊参数指示当前项目路径

Could you provide a minimal reproducer repository (or uploading a .zip file) for test?你能提供一个最小的复制器存储库(或上传 .zip 文件)进行测试吗?

ok,I'll pack it up

maryjeck commented 4 months ago

test.zip This is a test file

图片 显示这个错误

maryjeck commented 4 months ago

It will be recognized in previous versions

jfcherng commented 4 months ago

image

I am not able to reproduce this with the latest released LSP-pyright. Could you share your LSP-pyright's settings?


Could your issue be reproduced in Sublime Text's safe mode without changing any LSP-pyright's settings?

maryjeck commented 4 months ago
// Settings in here override those in "LSP-pyright/LSP-pyright.sublime-settings"
{
    "settings": {
        "python.analysis.extraPaths": [
            "F:\\miniconda3\\Lib",
            "F:\\miniconda3\\Lib\\site-packages",
            "./"
        ],
        "python.analysis.autoSearchPaths": true,
        "python.analysis.stubPath": "./typings",
        "python.analysis.diagnosticMode": "workspace",
        "python.analysis.diagnosticSeverityOverrides": {
            "reportUnboundVariable": "none",
            "reportGeneralTypeIssues": "information",
            "reportOptionalMemberAccess": "none",
            "reportUnusedImport": "warning"
        },
        "python.analysis.typeshedPaths": [
            "."
        ],
        "python.analysis.typeCheckingMode": "off",
        "pyright.disableOrganizeImports": true,
        "python.pythonPath": "F:\\miniconda3\\python.exe",
        "python.venvPath": ".",
    }
}
maryjeck commented 4 months ago

图片 here

jfcherng commented 4 months ago

Still can't reproduce, even with the exact plugin settings.

image

// Settings in here override those in "LSP-pyright/LSP-pyright.sublime-settings"
{
    "settings": {
        "python.analysis.extraPaths": [
            "C:\\Users\\jfcherng\\AppData\\Local\\Programs\\Python\\Python38\\Lib",
            "C:\\Users\\jfcherng\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages",
            "./"
        ],
        "python.analysis.autoSearchPaths": true,
        "python.analysis.stubPath": "./typings",
        "python.analysis.diagnosticMode": "workspace",
        "python.analysis.diagnosticSeverityOverrides": {
            "reportUnboundVariable": "none",
            "reportGeneralTypeIssues": "information",
            "reportOptionalMemberAccess": "none",
            "reportUnusedImport": "warning"
        },
        "python.analysis.typeshedPaths": [
            "."
        ],
        "python.analysis.typeCheckingMode": "off",
        "pyright.disableOrganizeImports": true,
        "python.pythonPath": "C:\\Users\\jfcherng\\AppData\\Local\\Programs\\Python\\Python38\\python.exe",
        "python.venvPath": ".",
    }
}
jfcherng commented 4 months ago

Could your issue be reproduced in Sublime Text's safe mode without changing any LSP-pyright's settings?

This hasn't been answered yet.

jfcherng commented 4 months ago

Someone probably has the same issue: https://github.com/microsoft/pyright/issues/7016#issuecomment-2042476674 But it's claimed fixed in pyright 1.1.360, which is LSP-pyright 1.3.1 🤔

maryjeck commented 4 months ago

Someone probably has the same issue: microsoft/pyright#7016 (comment) But it's claimed fixed in pyright 1.1.360, which is LSP-pyright 1.3.1 🤔

What I use is LSP-pyright 1.3.1

maryjeck commented 4 months ago

@jfcherng How to roll back to the previous version or a specific version

jfcherng commented 4 months ago

@jfcherng How to roll back to the previous version or a specific version

I guess basically you want Package Control to not manage it.

    "unmanaged_packages_ignore": [],

Or just overwrite language-server to an old version.

maryjeck commented 4 months ago

The status of version 1.3.2 is the same, and the reconfiguration is also the same, o(╥﹏╥)o

jfcherng commented 4 months ago

Have you found a working old version yet?

maryjeck commented 4 months ago

I don’t know how to roll back. After setting it up according to your method, it didn’t roll back to the previous version.

jfcherng commented 4 months ago

I don’t know how to roll back. After setting it up according to your method, it didn’t roll back to the previous version.

It prevents package control from managing (updating) it. It won't do rollback. It's you who have to do the rollback.

jfcherng commented 4 months ago

I don’t know how to roll back.

  1. Download the version you want. E.g., https://github.com/sublimelsp/LSP-pyright/archive/refs/tags/1.3.2.zip
  2. Decompress and put it like
Packages
└── LSP-pyright
    ├── commands.py
    ├── dependencies.json
    ├── language-server
    │   ├── package.json
    │   └── package-lock.json
    ├── ...

If you decompress it, it's LSP-pyright-1.3.2, you have to rename it as LSP-pyright and put it under Packages.

  1. Restart ST.

And if you are familiar with git, you will know you can do this with git and quickly switch among versions.

maryjeck commented 4 months ago

图片 This version works very well, and can be retired as long as the upstream version is not resolved.

maryjeck commented 4 months ago

Say something else 图片 Except for one package, lsp-basedpyright is also limited to this version. Is it because lsp is not set up properly or is it an upstream problem?

jfcherng commented 4 months ago

Just to confirm. LSP-pyright 1.3.0 and LSP LSP-basedpyright 1.1.0 both work for you and their next version failed, right?

maryjeck commented 4 months ago

Just to confirm. LSP-pyright 1.3.0 and LSP LSP-basedpyright 1.1.0 both work for you and their next version failed, right?

yes。The latter two versions of these two plug-ins do not work normal, whether it is a clean system or a safe mode

maryjeck commented 4 months ago

LSP-basedpyright

By the way, I replaced package.json and package-lock.json in LSP-basedpyright 1.1.0 with the same files in 1.1.2, and the result is that it runs perfectly. It seems that it is not an upstream problem. Please help to see if there is a setting problem

jfcherng commented 4 months ago

Could you try this: https://github.com/sublimelsp/LSP-pyright/archive/refs/heads/fix/import-not-found.zip

I doubt it may be fixed by https://github.com/sublimelsp/LSP-pyright/commit/273a22c3c97ef7eb87c15e9e95a061b5d084c8e6. This is the only behavior change that I notice between v1.3.0 and v1.3.1: https://github.com/sublimelsp/LSP-pyright/compare/1.3.0...1.3.1

maryjeck commented 4 months ago

Could you try this: https://github.com/sublimelsp/LSP-pyright/archive/refs/heads/fix/import-not-found.zip

I doubt it may be fixed by 273a22c. This is the only behavior change that I notice between v1.3.0 and v1.3.1: 1.3.0...1.3.1

sorry,Still not working

jfcherng commented 4 months ago

Unfortunately, I still can't spot other behavior different between 1.3.0...1.3.1.

jfcherng commented 4 months ago

Could you provide LSP-pyright's initialization logs (in LSP's log panel) for both v1.3.0 and v1.3.1 on your side?

maryjeck commented 4 months ago

log panel

How to view lsp logs? image

Like this?

jfcherng commented 4 months ago

log panel

How to view lsp logs? image

Like this?

yes, but a screenshot won't help. you can save them into files, zip them and upload here.

maryjeck commented 4 months ago

I will create a new clean version and send it to you.

jfcherng commented 4 months ago

I will create a new clean version and send it to you.

Appreciated.

maryjeck commented 3 months ago

lsp-pyright-logs.zip Sorry, I've been away on a business trip recently and haven't had the time to test it. I'm uploading it for you now.

maryjeck commented 3 months ago

I have determined that in my case, it is a problem with the upstream language-server. I still use 1.3.0

jfcherng commented 3 months ago

I have determined that in my case, it is a problem with the upstream language-server. I still use 1.3.0

You mean this is a pyright issue rather than lsp-pyright's?

jfcherng commented 3 months ago

lsp-pyright-logs.zip Sorry, I've been away on a business trip recently and haven't had the time to test it. I'm uploading it for you now.

Thanks for providing these information. But I need logs both when working and when not working, so we can find the difference.

maryjeck commented 3 months ago

diff.zip This is the log for 1.10 and 1.15.

jfcherng commented 3 months ago

OK (1.1.0?)

'diagnosticMode': 'workspace', 'extraPaths': ['F:\\miniconda3\\Lib', 'F:\\miniconda3\\Lib\\site-packages', '.\\', './', '', '.'],

FAILED (1.1.5?)

'diagnosticMode': 'openFilesOnly', 'extraPaths': [],

Expected to be failed but I doubt they are run under the exact same setup.


I think they have some fundamental differences so that I don't think they are run under the same setup. Hence diff.zip is probably useless.

I would expect the only environment difference when running for logs is the version number of LSP-basedpyright or LSP-pyright. Same ST workspace, plugin settings, project settings, same opened file etc... except that one uses LSP-basedpyright v1.1.0 and the other uses v1.1.5.