简体   繁体   English

VScode - pylance 无法正确识别错误,而 Jedi 未正确标记错误

[英]VScode - pylance doesn't identify the error correctly while Jedi doesn't mark the error correctly

I am newbie to VS code.我是 VS 代码的新手。 I am using only one version of Python - Python 3. I did the installation and configuration for python and I find the error identification and underlining is not working correctly.我只使用一个版本的 Python - Python 3。我为 Python 做了安装和配置,我发现错误识别和下划线不能正常工作。

Example: I removed the parenthesis of print -示例:我删除了 print 的括号 - pylance 强调打印语句的文本而不是打印

Pylance doesnt underline the print statement but the text inside. Pylance 没有在 print 语句下划线,而是在里面的文本下划线。 This annoying and I would like the red underlining to be under the print which would help a newbie to understand where the problem exactly is.这很烦人,我希望红色下划线位于印刷品下方,这将有助于新手了解问题究竟出在哪里。 The worst part is the error pointed out is completely different - "Statements must be separated by newlines or semicolons" and there are no 'quick fixes.最糟糕的是指出的错误是完全不同的——“语句必须用换行符或分号分隔”,并且没有“快速修复”。

While I am seen it point to the correct errors both positionally and semantically, I don't know what the setting to get that is -虽然我看到它在位置和语义上都指出了正确的错误,但我不知道要得到它的设置是什么 -

在此处输入图片说明

The above is what I want.以上就是我想要的。 Where it underlines correctly and gives the correct solution also.它在哪里正确强调并给出正确的解决方案。

What I tried:我试过的:

I tried meddling with the settings.json.我尝试干预settings.json。 I tried setting the language server to 'none' but that gave me a different result -我尝试将语言服务器设置为“无”,但这给了我不同的结果 - 在此处输入图片说明

While the error is pointed out in the Problems window below, the print part is not underlined and if I hover over the underline it shows only the description of the print statement.虽然在下面的问题窗口中指出了错误,但打印部分没有下划线,如果我将鼠标悬停在下划线上,它只会显示打印语句的描述。

Then I tried setting "python.languageServer": "Jedi" .然后我尝试设置"python.languageServer": "Jedi" Still no luck.仍然没有运气。 在此处输入图片说明

I would be immensely grateful for any help.我将不胜感激任何帮助。

You can enable linter you like or disable linter you don't like and change their option.您可以启用您喜欢的 linter 或禁用您不喜欢的 linter 并更改它们的选项。 Enabling linter is documented here .启用 linter 记录在此处 Pylint options are documented here , pylance options are documented here . 此处记录Pylint 选项, 此处记录pylance 选项。

But there won't be any magic setting that will make the error and underline better.但是不会有任何魔法设置可以使错误和下划线更好。 If there was a nicer error message in pylance/pylint or a more accurate underline it would be the default: there's no setting on your side that will change that.如果 pylance/pylint 中有更好的错误消息或更准确的下划线,它将是默认值:您这边没有任何设置会改变它。 Making python errors more understandable is VERY hard and something only a cython developer can do (they did in python 3.10) or the person writing the linter you integrated in vscode can do.让 python 错误更容易理解是非常困难的,只有 cython 开发人员才能做到(他们在 python 3.10 中做到了)或者编写集成在 vscode 中的 linter 的人才能做到。

So you can also open an issue in pylance or pylint so they address the issue your having.因此,您还可以在pylancepylint 中打开一个问题,以便他们解决您遇到的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM