问题标签 [pylance]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
37 浏览

python - 将所有非关键输入错误显示为警告

在 VSCode 中settings.json,我启用了 PyLance 的类型检查:

这会将所有输入问题显示为错误(红色下划线),即使代码是有效的 Python 并且将毫无问题地运行。

例如,以下代码是有效的 Python,并且有效:

...但是由于未绑定的情况,PyLance 显示错误a

在此处输入图像描述

我只想将 Python 拒绝的实际语法错误标记为“错误”,并将其他所有内容标记为警告。我可以为一个类别做到这一点:

对于所有此类错误,我该如何做到这一点?

0 投票
5 回答
18718 浏览

python - 为什么我不能在 VS Code 中导入请求?

我想使用请求模块,但是每当我尝试导入请求时,我都会收到以下消息:

我已经使用 pip 安装了 requests 模块,但我仍然收到此错误消息。

0 投票
1 回答
105 浏览

python - Pylance 正在从 BeautifulSoup 的 find_all -> ResultSet 中检测 PageElement 而不是 Tag

这是一段代码:

问题是,当我检查 的类型时soup_possible_form,Pylance 显示它是一个PageElement不正确的对象,它应该是一个Tag对象,因此name = soup_possible_form.get('name')被标记为错误,因为根据 Pylance 消息:

无法访问类型“PageElement”的成员“get”

成员“get”未知Pylance (reportGeneralTypeIssues)

我正在做一个我大量使用 BeautifulSoup 的项目,我不想# type: ignore在每次find_all -> ResultSet迭代中都使用它。

0 投票
1 回答
3036 浏览

python - 如何修复“x”未访问 Pylance

它说“x”没有被访问 Pylance 但我不知道为什么它曾经工作到现在。如果可以请帮忙。

在此处输入图像描述

0 投票
2 回答
2690 浏览

python - VS/Pylance 警告:无法解析导入“模块”

嗨,我收到以下警告(导入下方的波浪线)import "numpy" could not be resolved Pylance(reportMissingModuleSource),。执行代码没有问题 - 工作正常,只是警告(波浪线)。

在以下 github 页面中,它声明使用以下行更改 Settings.JSON "python.analysis.extraPaths": ["./sources"]

然而这并没有奏效。我还尝试将路径添加到当前目录,然后添加“源”,如图所示。但它也没有工作。

/home/imantha/workspace/python我正在使用bashwithcode .命令从这个入口点打开 vs 代码。

谁能知道我如何添加正确的路径。

在此处输入图像描述

0 投票
0 回答
60 浏览

python - pylance 未显示所有可用模块

在我使用 pylance 的 vs 代码中,当我键入 pygame 时,自动完成不会显示包示例中的所有模块。jedi 将在自动完成中显示显示模块,但在 pylance 中不会。我尝试更新 vscode、pylance 并搜索了谷歌,但我找不到解决方案,谁能告诉我问题是什么?

0 投票
1 回答
335 浏览

python - Visual Studio Code pylance 搜索文件夹

我有一个项目,里面有一些 python - python 是一个更大的东西的一部分 - 在根 git 的几个目录中有几个程序 - 在另一个目录中有一些通用代码。

运行正常 - 但 Visual Studio 代码中的 pylance 将所有依赖项视为错误,即使大多数依赖项位于我正在编辑的脚本的当前目录中。如果我打开该子目录,它们可以正常工作-但我真的希望在更大的项目级别上打开可视代码。

有什么方法可以在目录中的某处插入一个文件,告诉 pylance“这里是 python 搜索路径”之类的?

0 投票
0 回答
78 浏览

python - 我可以在 Pylance 中禁用第三方包的类型错误吗?

我使用的一些包没有键入提示它们的代码,所以当我使用它们时,Pylance 一直告诉我我使用的函数有部分未知类型,这是我无法解决的问题。有没有办法禁用此类错误?

0 投票
1 回答
33 浏览

pandas - Visual Studio doesn't show help pop up with DataFrame from awswrangler

I am using VS Code with Microsoft Python extension. If I create a Pandas dataframe and write the name of the variable VS Code popups all kinds of help text. However, if I have a variable made using wr.athena.read_sql_query, I don't get any help text even if the variable is a Pandas dataframe.

Is there a way to make VS Code realize that df2 in the example is a Pandas DataFrame and get the help text?

0 投票
1 回答
727 浏览

python - 导入“flask_mysqldb”无法解析 Pylance(reportMissingImports)

呃,我得到这个错误

导入“flask_mysqldb”无法解析 Pylance(reportMissingImports)

而且我真的不知道我是否遗漏了一些东西,因为当我尝试安装东西时,它说“要求已经满足”,我很恐慌,因为我不知道自己做错了什么。这是我正在使用的实际代码,但我不能使用与数据库相关的任何内容,因为第二行不起作用:

from flask import Flask, render_template, request, redirect, url_for, flash

from flask_mysqldb import MySQL