如何在Python中使用仅VS代码的自动完成名称?

2024-10-03 17:20:11 发布

您现在位置:Python中文网/ 问答频道 /正文

最近(目前在1.58.2上),当自动完成名称时,VS代码似乎变得更加“有用”。以前,我会打字

except pydantic.Val

然后,当点击标签时,我会以

except pydantic.ValidationError

但是现在,从int这样的内置库到第三方库,VS代码得到了suuuper的帮助,认为我想调用它,并将签名作为一个片段提供给我:

enter image description here

我怎样才能恢复“愚蠢”的行为?我可以使用smart,但我想我至少需要用一个打开的paren来发出信号,而不是我需要手动选择删除的文本


我当前的设置非常单调:

{
    "workbench.editorAssociations": {
        "*.ipynb": "jupyter-notebook"
    },
    "window.titleBarStyle": "custom",
    "gitlens.blame.separateLines": false,
    "gitlens.codeLens.enabled": false,
    "editor.renderWhitespace": "all",
    "python.formatting.blackArgs": [
        "--experimental-string-processing"
    ],
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "files.trimTrailingWhitespace": true,
    "window.zoomLevel": 1,
    "notebook.cellToolbarLocation": {
        "default": "right",
        "jupyter-notebook": "left"
    }
}

有一个设置python.autoComplete.addBrackets是当前默认的false,即使我在设置中显式地设置它,或者设置它true,就我所知没有什么区别

扩展:

eamodio.gitlens
EFanZh.graphviz-preview
joaompinto.vscode-graphviz
lextudio.restructuredtext
mechatroner.rainbow-csv
ms-azuretools.vscode-docker
ms-python.python
ms-toolsai.jupyter
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode.sublime-keybindings
mscgenjs.vscode-mscgen
rust-lang.rust
samuelcolvin.jinjahtml
sleistner.vscode-fileutils
tamasfe.even-better-toml
tsandall.opa

Tags: 代码falsetrueremotejupyterfileswindowvscode
1条回答
网友
1楼 · 发布于 2024-10-03 17:20:11

您正在使用JediLSP语言服务器,不是吗

您可以修改参数并使用Tab跳转到下一个参数

你能试着切换到Pylance语言服务器吗?它仍然有“愚蠢”的行为。您可以在settings.json文件中进行设置:

"python.languageServer": "Pylance",

相关问题 更多 >