python - 如何在 Python 中仅使用 VS Code 自动完成名称?

标签 python visual-studio-code vscode-python

最近(当前为 1.58.2),VS Code 在自动完成名称时似乎变得更加“有用”。以前,我可以输入

except pydantic.Val

然后当点击Tab时我会得到

except pydantic.ValidationError

但现在,在从 int 这样的内置函数到第三方库的情况下,VS Code 会得到 suuuuper 的帮助,并认为我想调用它并给我签名:一个片段:

enter image description here

如何恢复“愚蠢”行为?我很聪明,但恕我直言,我至少应该需要用开放括号来表示它,而不是它呕吐我需要手动选择删除的文本。


我当前的设置非常乏味:

{
    "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

最佳答案

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

可以修改参数并通过Tab跳转到下一个参数。

您可以尝试切换到 Pylance 语言服务器吗?依然是“笨”的行为。您可以在settings.json 文件中进行设置:

"python.languageServer": "Pylance",

关于python - 如何在 Python 中仅使用 VS Code 自动完成名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68628046/

相关文章:

Ubuntu中的Python导入模块和文件

python - 安装和运行 Tensorflow 时出现 ValueError

python - 在 vs code python 调试控制台中运行循环/多行

visual-studio-code - 在 VS Code 中,如何获取当前选择的 Python 的路径?

python - 如何以抑制 Pylance 警告的方式声明没有值的类变量

python - 如何确保所有字符串文字在 python 中都是 unicode

python 的 print 函数不完全是一个普通的函数?

c# - 使用带有 C# 的 Selenium WebDriver 迭代链接

python - 在 VSC 中,如何在 Python 中重命名模块时激活 "refactor preview"?

python - VS Code "Run selection/line in Python interactive window"根本不起作用