Vscode 使用 jedi + pyright 时显示函数文档字符串两次

Vscode shows function docstrings twice when using jedi + pyright

我正在使用安装了 jedi 和 pyright 的 VSCodium(vscode 的开源版本)。这导致函数文档字符串显示两次(见附图),因为 jedi 和 pyright 都显示了它们。

有没有办法在不完全禁用 jedi 的情况下禁用 jedi 的这个单一功能?

能否尝试切换到 Pylance Language Server? pyright 已内置:

Pyright has detected that the Pylance extension is installed. Pylance includes the functionality of Pyright, and running both of these extensions can lead to problems. Pyright will disable itself. Uninstall or disable Pyright to avoid this message.

事实证明,Pyright 本身是一个语言服务器,因此 vscode 同时显示 pyright 和 jedi 的输出。在您的配置中添加 "python.languageServer": "None", 可以修复此问题。

另请参阅:https://github.com/microsoft/pyright/issues/390, https://github.com/microsoft/vscode-python/issues/7010 and https://github.com/microsoft/pyright/issues/201

更新:另一种方法是继续使用 jedi 或任何其他语言服务器,并将“pyright.disableLanguageServices”设置为 true。