Is using Discord intents with discord.py "bugged" with pylint as I get a pylint error: "Assigning to attribute " " not defined in class slots"

Is using Discord intents with discord.py "bugged" with pylint as I get a pylint error: "Assigning to attribute " " not defined in class slots"

我目前正在使用最新版本的 pylint、python3.92 和 discord.py.
开发一个小型 discord 机器人 在使用 discord intents 时,我遇到了一个让我难过的 pylint 错误。
这是一个更普遍的问题,因为我正在做的任何事情仍在工作,并且正在做我打算在我的实际项目中做的事情。
然而,这个我似乎无法解决或摆脱的错误严重困扰着我,因为据我所知,我根据文档使用 discord.py 意图。
此代码段来自测试机器人,用于展示具体错误。

import discord
from discord.ext import commands

intents = discord.Intents.default()

intents.members = True 
intents.presences = True

bot = commands.Bot(command_prefix='.', intents=intents)

@bot.command()
async def ping(ctx):
    ctx.send("pong")

bot.run('TOKEN')

现在 pylint 向我展示了这段代码中的两个错误,都考虑了 intent 属性分配。

来自文档:

 import discord
 intents = discord.Intents.default()
 intents.typing = False
 intents.presences = False

 # Somewhere else:
 # client = discord.Client(intents=intents)
 # or
 # from discord.ext import commands
 # bot = commands.Bot(command_prefix='!', intents=intents)

我发现的一种可能性是以下解决方法:

intents = discord.Intents(members=True, presences=True)

然而,由于我计划在一个机器人中使用不同的功能,并且不想手动添加我需要的所有意图,我计划尽可能坚持 discord.Intents.default()

据我所知,这些错误不会妨碍功能或导致任何其他错误。错误与不同类型的意图相同,而不仅仅是特权意图。 我的问题是:

  1. 我是不是做错了什么?
  2. 我怎样才能摆脱这些 错误?

不幸的是,我对语言的了解,discord.py 和 pylint 还不够先进,无法改变现状并以适当的方式消除错误。

提前致谢!

理论上,错误的代码应该是这样的(source):

class Foo:
    __slots__ = ('bar',)

    def __init__(self, bar, baz):
        self.bar = bar
        self.baz = baz # [assigning-non-slot]
        self.setup()

    def setup(self):
        pass

正确的代码如下:

class Foo:
    __slots__ = ('bar', 'baz')

    def __init__(self, bar, baz):
        self.bar = bar
        self.baz = baz
        self.setup()

    def setup(self):
        pass

现在,如果当前表单中的代码适合您,尤其是如果这是使用您的依赖项的官方且更简单的方式...那么它是来自 pylint 的误报,您可以使用 # pylint: disable=assigning-non-slot 甚至整个项目 pylintrc