LSP-pyright icon indicating copy to clipboard operation
LSP-pyright copied to clipboard

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

Open maryjeck opened this issue 10 months ago • 41 comments

before the version 1.3.1,it's auto include it

maryjeck avatar Apr 27 '24 16:04 maryjeck

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 avatar Apr 27 '24 19:04 jfcherng

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 avatar Apr 27 '24 19:04 jfcherng

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

jfcherng avatar Apr 28 '24 14:04 jfcherng

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

maryjeck avatar Apr 29 '24 04:04 maryjeck

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?

jfcherng avatar Apr 29 '24 04:04 jfcherng

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 avatar Apr 29 '24 04:04 maryjeck

test.zip This is a test file

图片 显示这个错误

maryjeck avatar Apr 29 '24 04:04 maryjeck

It will be recognized in previous versions

maryjeck avatar Apr 29 '24 04:04 maryjeck

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?

jfcherng avatar Apr 29 '24 04:04 jfcherng

// 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 avatar Apr 29 '24 06:04 maryjeck

图片 here

maryjeck avatar Apr 29 '24 06:04 maryjeck

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 avatar Apr 29 '24 12:04 jfcherng

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 avatar Apr 29 '24 12:04 jfcherng

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 🤔

jfcherng avatar Apr 29 '24 12:04 jfcherng

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 avatar Apr 29 '24 13:04 maryjeck

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

maryjeck avatar Apr 30 '24 14:04 maryjeck

@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.

jfcherng avatar Apr 30 '24 14:04 jfcherng

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

maryjeck avatar May 04 '24 13:05 maryjeck

Have you found a working old version yet?

jfcherng avatar May 04 '24 13:05 jfcherng

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.

maryjeck avatar May 04 '24 13:05 maryjeck

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 avatar May 04 '24 13:05 jfcherng

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.

jfcherng avatar May 04 '24 13:05 jfcherng

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

maryjeck avatar May 04 '24 14:05 maryjeck

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?

maryjeck avatar May 04 '24 14:05 maryjeck

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?

jfcherng avatar May 04 '24 14:05 jfcherng

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 avatar May 04 '24 14:05 maryjeck

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

maryjeck avatar May 05 '24 02:05 maryjeck

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

jfcherng avatar May 06 '24 15:05 jfcherng

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

maryjeck avatar May 07 '24 03:05 maryjeck

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

jfcherng avatar May 07 '24 13:05 jfcherng