mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-12 16:59:50 +00:00
Fix some type checker errors and remove some type ignores
Caught from an upgraded Pyright
This commit is contained in:
parent
6d75d2e937
commit
1192d842e1
@ -210,7 +210,7 @@ class Choice(Generic[ChoiceT]):
|
|||||||
return {
|
return {
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'value': self.value,
|
'value': self.value,
|
||||||
} # type: ignore -- Type checker does not understand this literal.
|
}
|
||||||
|
|
||||||
|
|
||||||
class AppCommandChannel(Hashable):
|
class AppCommandChannel(Hashable):
|
||||||
|
@ -500,7 +500,8 @@ class Cog(metaclass=CogMeta):
|
|||||||
command.cog = self
|
command.cog = self
|
||||||
if command.parent is None:
|
if command.parent is None:
|
||||||
try:
|
try:
|
||||||
bot.add_command(command)
|
# Type checker does not understand the generic bounds here
|
||||||
|
bot.add_command(command) # type: ignore
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# undo our additions
|
# undo our additions
|
||||||
for to_undo in self.__cog_commands__[:index]:
|
for to_undo in self.__cog_commands__[:index]:
|
||||||
|
@ -391,7 +391,7 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
|||||||
try:
|
try:
|
||||||
if hasattr(entity, '__cog_commands__'):
|
if hasattr(entity, '__cog_commands__'):
|
||||||
injected = wrap_callback(cmd.send_cog_help)
|
injected = wrap_callback(cmd.send_cog_help)
|
||||||
return await injected(entity) # type: ignore
|
return await injected(entity)
|
||||||
elif isinstance(entity, Group):
|
elif isinstance(entity, Group):
|
||||||
injected = wrap_callback(cmd.send_group_help)
|
injected = wrap_callback(cmd.send_group_help)
|
||||||
return await injected(entity)
|
return await injected(entity)
|
||||||
|
@ -401,7 +401,7 @@ class MessageConverter(IDConverter[discord.Message]):
|
|||||||
return message
|
return message
|
||||||
channel = PartialMessageConverter._resolve_channel(ctx, guild_id, channel_id)
|
channel = PartialMessageConverter._resolve_channel(ctx, guild_id, channel_id)
|
||||||
if not channel or not isinstance(channel, discord.abc.Messageable):
|
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:
|
try:
|
||||||
return await channel.fetch_message(message_id)
|
return await channel.fetch_message(message_id)
|
||||||
except discord.NotFound:
|
except discord.NotFound:
|
||||||
|
@ -485,7 +485,8 @@ class FlagConverter(metaclass=FlagsMeta):
|
|||||||
flags = cls.__commands_flags__
|
flags = cls.__commands_flags__
|
||||||
for flag in flags.values():
|
for flag in flags.values():
|
||||||
if callable(flag.default):
|
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)
|
setattr(self, flag.attribute, default)
|
||||||
else:
|
else:
|
||||||
setattr(self, flag.attribute, flag.default)
|
setattr(self, flag.attribute, flag.default)
|
||||||
@ -584,7 +585,8 @@ class FlagConverter(metaclass=FlagsMeta):
|
|||||||
raise MissingRequiredFlag(flag)
|
raise MissingRequiredFlag(flag)
|
||||||
else:
|
else:
|
||||||
if callable(flag.default):
|
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)
|
setattr(self, flag.attribute, default)
|
||||||
else:
|
else:
|
||||||
setattr(self, flag.attribute, flag.default)
|
setattr(self, flag.attribute, flag.default)
|
||||||
|
@ -713,13 +713,15 @@ class ConnectionState:
|
|||||||
self._command_tree._from_interaction(interaction)
|
self._command_tree._from_interaction(interaction)
|
||||||
elif data['type'] == 3: # interaction component
|
elif data['type'] == 3: # interaction component
|
||||||
# These keys are always there for this interaction type
|
# These keys are always there for this interaction type
|
||||||
custom_id = interaction.data['custom_id'] # type: ignore
|
inner_data = data['data']
|
||||||
component_type = interaction.data['component_type'] # type: ignore
|
custom_id = inner_data['custom_id']
|
||||||
|
component_type = inner_data['component_type']
|
||||||
self._view_store.dispatch_view(component_type, custom_id, interaction)
|
self._view_store.dispatch_view(component_type, custom_id, interaction)
|
||||||
elif data['type'] == 5: # modal submit
|
elif data['type'] == 5: # modal submit
|
||||||
# These keys are always there for this interaction type
|
# These keys are always there for this interaction type
|
||||||
custom_id = interaction.data['custom_id'] # type: ignore
|
inner_data = data['data']
|
||||||
components = interaction.data['components'] # type: ignore
|
custom_id = inner_data['custom_id']
|
||||||
|
components = inner_data['components']
|
||||||
self._view_store.dispatch_modal(custom_id, interaction, components) # type: ignore
|
self._view_store.dispatch_modal(custom_id, interaction, components) # type: ignore
|
||||||
self.dispatch('interaction', interaction)
|
self.dispatch('interaction', interaction)
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class _BaseMessageComponentInteractionData(TypedDict):
|
|||||||
|
|
||||||
|
|
||||||
class ButtonMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
class ButtonMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
||||||
type: Literal[2]
|
component_type: Literal[2]
|
||||||
|
|
||||||
|
|
||||||
class SelectMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
class SelectMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
||||||
|
@ -75,6 +75,7 @@ has_nacl: bool
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import nacl.secret # type: ignore
|
import nacl.secret # type: ignore
|
||||||
|
import nacl.utils # type: ignore
|
||||||
|
|
||||||
has_nacl = True
|
has_nacl = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user