From 1b9bd3aa352c8bbc5d813a91b257e5f93f79f2c2 Mon Sep 17 00:00:00 2001 From: CringleySDays Date: Thu, 5 Jan 2023 17:55:01 +0000 Subject: [PATCH 1/2] typehinting arguments and variable --- examples/views/channel_select.py | 8 ++++---- examples/views/role_select.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/views/channel_select.py b/examples/views/channel_select.py index 2c2ba8e8db..64dbccdf72 100644 --- a/examples/views/channel_select.py +++ b/examples/views/channel_select.py @@ -9,18 +9,18 @@ class DropdownView(discord.ui.View): @discord.ui.channel_select( placeholder="Select channels...", min_values=1, max_values=3 ) # Users can select a maximum of 3 channels in the dropdown - async def channel_select_dropdown(self, select, interaction): + async def channel_select_dropdown(self, select: discord.ui.Select, interaction: discord.Interaction) -> None: await interaction.response.send_message( f"You selected the following channels:" + f", ".join(f"{channel.mention}" for channel in select.values) ) -bot = discord.Bot(debug_guilds=[...]) +bot: discord.Bot = discord.Bot(debug_guilds=[...]) @bot.slash_command() -async def channel_select(ctx: discord.ApplicationContext): +async def channel_select(ctx: discord.ApplicationContext) -> None: """Sends a message with our dropdown that contains a channel select.""" # Create the view containing our dropdown @@ -31,7 +31,7 @@ async def channel_select(ctx: discord.ApplicationContext): @bot.event -async def on_ready(): +async def on_ready() -> None: print(f"Logged in as {bot.user} (ID: {bot.user.id})") print("------") diff --git a/examples/views/role_select.py b/examples/views/role_select.py index c3774b4de5..657f3812b9 100644 --- a/examples/views/role_select.py +++ b/examples/views/role_select.py @@ -9,18 +9,18 @@ class DropdownView(discord.ui.View): @discord.ui.role_select( placeholder="Select roles...", min_values=1, max_values=3 ) # Users can select a maximum of 3 roles in the dropdown - async def role_select_dropdown(self, select, interaction): + async def role_select_dropdown(self, select: discord.ui.Select, interaction: discord.Interaction) -> None: await interaction.response.send_message( f"You selected the following roles:" + f", ".join(f"{role.mention}" for role in select.values) ) -bot = discord.Bot(debug_guilds=[...]) +bot: discord.Bot = discord.Bot(debug_guilds=[...]) @bot.slash_command() -async def role_select(ctx: discord.ApplicationContext): +async def role_select(ctx: discord.ApplicationContext) -> None: """Sends a message with our dropdown that contains a role select.""" # Create the view containing our dropdown @@ -31,7 +31,7 @@ async def role_select(ctx: discord.ApplicationContext): @bot.event -async def on_ready(): +async def on_ready() -> None: print(f"Logged in as {bot.user} (ID: {bot.user.id})") print("------") From 74bd724c9335c8ec87a0fe3504563dd221243bcf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 18:04:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/views/channel_select.py | 4 +++- examples/views/role_select.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/views/channel_select.py b/examples/views/channel_select.py index 64dbccdf72..df00614629 100644 --- a/examples/views/channel_select.py +++ b/examples/views/channel_select.py @@ -9,7 +9,9 @@ class DropdownView(discord.ui.View): @discord.ui.channel_select( placeholder="Select channels...", min_values=1, max_values=3 ) # Users can select a maximum of 3 channels in the dropdown - async def channel_select_dropdown(self, select: discord.ui.Select, interaction: discord.Interaction) -> None: + async def channel_select_dropdown( + self, select: discord.ui.Select, interaction: discord.Interaction + ) -> None: await interaction.response.send_message( f"You selected the following channels:" + f", ".join(f"{channel.mention}" for channel in select.values) diff --git a/examples/views/role_select.py b/examples/views/role_select.py index 657f3812b9..f2822e7b4c 100644 --- a/examples/views/role_select.py +++ b/examples/views/role_select.py @@ -9,7 +9,9 @@ class DropdownView(discord.ui.View): @discord.ui.role_select( placeholder="Select roles...", min_values=1, max_values=3 ) # Users can select a maximum of 3 roles in the dropdown - async def role_select_dropdown(self, select: discord.ui.Select, interaction: discord.Interaction) -> None: + async def role_select_dropdown( + self, select: discord.ui.Select, interaction: discord.Interaction + ) -> None: await interaction.response.send_message( f"You selected the following roles:" + f", ".join(f"{role.mention}" for role in select.values)