diff --git a/discord/app_commands/models.py b/discord/app_commands/models.py index 3a1e2bb35..3526eab68 100644 --- a/discord/app_commands/models.py +++ b/discord/app_commands/models.py @@ -210,7 +210,7 @@ class Choice(Generic[ChoiceT]): return { 'name': self.name, 'value': self.value, - } # type: ignore -- Type checker does not understand this literal. + } class AppCommandChannel(Hashable): diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 33952ee88..1cd4f8895 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -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]: diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index 8acfa09e5..3297c056f 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -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) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 2d68ea8bd..4ea649490 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -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: diff --git a/discord/ext/commands/flags.py b/discord/ext/commands/flags.py index 8de2f237c..64d57a145 100644 --- a/discord/ext/commands/flags.py +++ b/discord/ext/commands/flags.py @@ -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) diff --git a/discord/state.py b/discord/state.py index 88b9c5037..f7a338f15 100644 --- a/discord/state.py +++ b/discord/state.py @@ -713,13 +713,15 @@ class ConnectionState: self._command_tree._from_interaction(interaction) elif data['type'] == 3: # interaction component # These keys are always there for this interaction type - custom_id = interaction.data['custom_id'] # type: ignore - component_type = interaction.data['component_type'] # type: ignore + inner_data = data['data'] + custom_id = inner_data['custom_id'] + component_type = inner_data['component_type'] self._view_store.dispatch_view(component_type, custom_id, interaction) elif data['type'] == 5: # modal submit # These keys are always there for this interaction type - custom_id = interaction.data['custom_id'] # type: ignore - components = interaction.data['components'] # type: ignore + inner_data = data['data'] + custom_id = inner_data['custom_id'] + components = inner_data['components'] self._view_store.dispatch_modal(custom_id, interaction, components) # type: ignore self.dispatch('interaction', interaction) diff --git a/discord/types/interactions.py b/discord/types/interactions.py index a2c5fd4d0..8c097c0ed 100644 --- a/discord/types/interactions.py +++ b/discord/types/interactions.py @@ -159,7 +159,7 @@ class _BaseMessageComponentInteractionData(TypedDict): class ButtonMessageComponentInteractionData(_BaseMessageComponentInteractionData): - type: Literal[2] + component_type: Literal[2] class SelectMessageComponentInteractionData(_BaseMessageComponentInteractionData): diff --git a/discord/voice_client.py b/discord/voice_client.py index 67490e084..f0b03a669 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -75,6 +75,7 @@ has_nacl: bool try: import nacl.secret # type: ignore + import nacl.utils # type: ignore has_nacl = True except ImportError: