【问题标题】:How do I have VS Code only autocomplete names in Python?如何在 Python 中仅使用 VS Code 自动完成名称?
【发布时间】:2021-08-02 21:21:09
【问题描述】:

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

然后当点击 Tab 我会结束

except pydantic.ValidationError

但现在在从 int 等内置函数到第三方库的情况下,VS Code suuuuper 很有帮助,并且认为我想调用它并给我作为 sn-p 的签名:

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


我目前的设置很乏味:

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

【问题讨论】:

  • 你有 Github Copilot 吗?使用 Copilot 时,您的光标不应该移动,建议的文本应该是灰色的,但有可能......
  • 您最近是否安装或启用了一些 sn-ps?
  • 没有 Copilot,没有新的扩展。添加了扩展列表。

标签: python visual-studio-code vscode-python


【解决方案1】:

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

可以修改参数,用Tab跳转到下一个。

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

"python.languageServer": "Pylance",

【讨论】:

  • 那行得通。我在哪里可以抱怨这个?我并不是说这个特性毫无意义,但经常有人会提到文字函数、类、类型(对于装饰器来说也超级烦人)
  • @Steven-MSFT 它内置在 Python 扩展中。所以,我认为您可以在herehere 中提交功能
猜你喜欢
  • 1970-01-01
  • 2021-10-30
  • 2019-07-28
  • 1970-01-01
  • 1970-01-01
  • 2016-09-02
  • 2018-07-07
  • 1970-01-01
  • 2017-11-21
相关资源
最近更新 更多