mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-07 10:22:59 +00:00
Fix some type checker errors and remove some type ignores
Caught from an upgraded Pyright
This commit is contained in:
@ -500,7 +500,8 @@ class Cog(metaclass=CogMeta):
|
||||
command.cog = self
|
||||
if command.parent is None:
|
||||
try:
|
||||
bot.add_command(command)
|
||||
# Type checker does not understand the generic bounds here
|
||||
bot.add_command(command) # type: ignore
|
||||
except Exception as e:
|
||||
# undo our additions
|
||||
for to_undo in self.__cog_commands__[:index]:
|
||||
|
@ -391,7 +391,7 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
||||
try:
|
||||
if hasattr(entity, '__cog_commands__'):
|
||||
injected = wrap_callback(cmd.send_cog_help)
|
||||
return await injected(entity) # type: ignore
|
||||
return await injected(entity)
|
||||
elif isinstance(entity, Group):
|
||||
injected = wrap_callback(cmd.send_group_help)
|
||||
return await injected(entity)
|
||||
|
@ -401,7 +401,7 @@ class MessageConverter(IDConverter[discord.Message]):
|
||||
return message
|
||||
channel = PartialMessageConverter._resolve_channel(ctx, guild_id, channel_id)
|
||||
if not channel or not isinstance(channel, discord.abc.Messageable):
|
||||
raise ChannelNotFound(channel_id) # type: ignore - channel_id won't be None here
|
||||
raise ChannelNotFound(channel_id)
|
||||
try:
|
||||
return await channel.fetch_message(message_id)
|
||||
except discord.NotFound:
|
||||
|
@ -485,7 +485,8 @@ class FlagConverter(metaclass=FlagsMeta):
|
||||
flags = cls.__commands_flags__
|
||||
for flag in flags.values():
|
||||
if callable(flag.default):
|
||||
default = await maybe_coroutine(flag.default, ctx)
|
||||
# Type checker does not understand that flag.default is a Callable
|
||||
default = await maybe_coroutine(flag.default, ctx) # type: ignore
|
||||
setattr(self, flag.attribute, default)
|
||||
else:
|
||||
setattr(self, flag.attribute, flag.default)
|
||||
@ -584,7 +585,8 @@ class FlagConverter(metaclass=FlagsMeta):
|
||||
raise MissingRequiredFlag(flag)
|
||||
else:
|
||||
if callable(flag.default):
|
||||
default = await maybe_coroutine(flag.default, ctx)
|
||||
# Type checker does not understand flag.default is a Callable
|
||||
default = await maybe_coroutine(flag.default, ctx) # type: ignore
|
||||
setattr(self, flag.attribute, default)
|
||||
else:
|
||||
setattr(self, flag.attribute, flag.default)
|
||||
|
Reference in New Issue
Block a user