python - 如何修复“x”未访问 Pylance
问题描述
它说“x”没有被访问 Pylance 但我不知道为什么它曾经工作到现在。如果可以请帮忙。
troll3= ["troll" , "ulikemen" , "someone-is-in-my-house" , ";/","amogsus"]
@client.command()
@commands.has_permissions(administrator=True)
async def nuke(ctx):
guild = ctx.guild
await ctx.author.send(f'fake nuke command lol {ctx.author.mention}')
for x in range(5):
time.sleep(1)
await ctx.send(f'[+] role: {(random.choice(troll3))} has been created')
try:
for channel in guild.channels:
await ctx.send(f'channel: {channel.name} was deleted')
except:
await ctx.send('g')
解决方案
如果您使用一些 linter/formatter(如 flake8、autopep8 等),您可以更改这些设置。在 VSCode 上(从你的编辑器截图中猜测),你可以忽略特定的错误或警告。(在这种情况下,F401
是您要忽略的错误。)
在path/to/.vscode/settings.json
{
.
.
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--ignore=E111, E114, E402, E501, F401"
],
.
.
}
或者更简单地说,您可以禁用 linting 或格式化包。
{
.
.
"python.linting.flake8Enabled": false,
.
.
}
或者,您可以禁用 linting 或格式化本身。
{
.
.
"python.linting.enabled": false,
.
.
}
推荐阅读
- javascript - Ajv 响应编号为字符串,带有 coerceTypes: true
- asynchronous - 当在同一个 React 块中使用不同的线程调度程序时会发生什么?
- python - 如何根据两个值对字典进行分组?
- ansible - 查找给定文件的 Yaml 脚本是否为空
- dart - 如何在扩展小部件前面制作键盘
- excel - 彼此减去行,但跳过字符串
- python - 如何使用请求或其他库从该网页获取 json?
- apache-spark - 纱线调度程序页面上的内存、vcore 和磁盘是什么?
- c++ - QTest 覆盖漆法
- python - 有人可以向我解释这段代码吗?我需要了解 Python for 循环的人