首页 > 解决方案 > 如何修复“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')

在此处输入图像描述

标签: pythonpylance

解决方案


如果您使用一些 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,
    .
    .
}

推荐阅读