Skip to content

Commit

Permalink
fix(typing): Reduce number of Unknowns in public APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
elenakrittik committed Mar 19, 2024
1 parent 17b741a commit 985d8a9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ async def move(
) -> None:
...

async def move(self, **kwargs) -> None:
async def move(self, **kwargs: Any) -> None:
"""|coro|
A rich interface to help move a channel relative to other channels.
Expand Down
2 changes: 1 addition & 1 deletion disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,7 @@ async def move(
...

@utils.copy_doc(disnake.abc.GuildChannel.move)
async def move(self, **kwargs) -> None:
async def move(self, **kwargs: Any) -> None:
kwargs.pop("category", None)
return await super().move(**kwargs)

Expand Down
8 changes: 5 additions & 3 deletions disnake/ext/commands/base_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Self:
self.__original_kwargs__ = {k: v for k, v in kwargs.items() if v is not None}
return self

def __init__(self, func: CommandCallback, *, name: Optional[str] = None, **kwargs) -> None:
def __init__(self, func: CommandCallback, *, name: Optional[str] = None, **kwargs: Any) -> None:
self.__command_flag__ = None
self._callback: CommandCallback = func
self.name: str = name or func.__name__
Expand Down Expand Up @@ -281,7 +281,9 @@ def remove_check(self, func: AppCheck) -> None:
except ValueError:
pass

async def __call__(self, interaction: ApplicationCommandInteraction, *args, **kwargs) -> Any:
async def __call__(
self, interaction: ApplicationCommandInteraction, *args: Any, **kwargs: Any
) -> Any:
"""|coro|
Calls the internal callback that the application command holds.
Expand Down Expand Up @@ -381,7 +383,7 @@ def get_cooldown_retry_after(self, inter: ApplicationCommandInteraction) -> floa
return 0.0

# This method isn't really usable in this class, but it's usable in subclasses.
async def invoke(self, inter: ApplicationCommandInteraction, *args, **kwargs) -> None:
async def invoke(self, inter: ApplicationCommandInteraction, *args: Any, **kwargs: Any) -> None:
await self.prepare(inter)

try:
Expand Down
20 changes: 14 additions & 6 deletions disnake/ext/commands/ctx_menus_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
nsfw: Optional[bool] = None,
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
**kwargs,
**kwargs: Any,
) -> None:
name_loc = Localized._cast(name, False)
super().__init__(func, name=name_loc.string, **kwargs)
Expand Down Expand Up @@ -122,7 +122,11 @@ async def _call_external_error_handlers(
inter.bot.dispatch("user_command_error", inter, error)

async def __call__(
self, interaction: ApplicationCommandInteraction, target: Any = None, *args, **kwargs
self,
interaction: ApplicationCommandInteraction,
target: Any = None,
*args: Any,
**kwargs: Any,
) -> None:
# the target may just not be passed in
args = (target or interaction.target,) + args
Expand Down Expand Up @@ -180,7 +184,7 @@ def __init__(
nsfw: Optional[bool] = None,
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
**kwargs,
**kwargs: Any,
) -> None:
name_loc = Localized._cast(name, False)
super().__init__(func, name=name_loc.string, **kwargs)
Expand Down Expand Up @@ -218,7 +222,11 @@ async def _call_external_error_handlers(
inter.bot.dispatch("message_command_error", inter, error)

async def __call__(
self, interaction: ApplicationCommandInteraction, target: Any = None, *args, **kwargs
self,
interaction: ApplicationCommandInteraction,
target: Any = None,
*args: Any,
**kwargs: Any,
) -> None:
# the target may just not be passed in
args = (target or interaction.target,) + args
Expand All @@ -237,7 +245,7 @@ def user_command(
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[InteractionCommandCallback[CogT, UserCommandInteraction, P]], InvokableUserCommand]:
"""A shortcut decorator that builds a user command.
Expand Down Expand Up @@ -316,7 +324,7 @@ def message_command(
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[
[InteractionCommandCallback[CogT, MessageCommandInteraction, P]],
InvokableMessageCommand,
Expand Down
6 changes: 3 additions & 3 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def slash_command(
connectors: Optional[Dict[str, str]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[CommandCallback], InvokableSlashCommand]:
"""A shortcut decorator that invokes :func:`~disnake.ext.commands.slash_command` and adds it to
the internal command list.
Expand Down Expand Up @@ -585,7 +585,7 @@ def user_command(
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[
[InteractionCommandCallback[CogT, UserCommandInteraction, P]], InvokableUserCommand
]:
Expand Down Expand Up @@ -662,7 +662,7 @@ def message_command(
guild_ids: Optional[Sequence[int]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[
[InteractionCommandCallback[CogT, MessageCommandInteraction, P]], InvokableMessageCommand
]:
Expand Down
16 changes: 8 additions & 8 deletions disnake/ext/commands/slash_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(
parent: InvokableSlashCommand,
*,
name: LocalizedOptional = None,
**kwargs,
**kwargs: Any,
) -> None:
name_loc = Localized._cast(name, False)
super().__init__(func, name=name_loc.string, **kwargs)
Expand Down Expand Up @@ -193,7 +193,7 @@ def sub_command(
options: Optional[list] = None,
connectors: Optional[dict] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[CommandCallback], SubCommand]:
"""A decorator that creates a subcommand in the subcommand group.
Parameters are the same as in :class:`InvokableSlashCommand.sub_command`
Expand Down Expand Up @@ -272,7 +272,7 @@ def __init__(
description: LocalizedOptional = None,
options: Optional[list] = None,
connectors: Optional[Dict[str, str]] = None,
**kwargs,
**kwargs: Any,
) -> None:
name_loc = Localized._cast(name, False)
super().__init__(func, name=name_loc.string, **kwargs)
Expand Down Expand Up @@ -345,7 +345,7 @@ async def _call_autocompleter(
) -> Optional[Choices]:
return await _call_autocompleter(self, param, inter, user_input)

async def invoke(self, inter: ApplicationCommandInteraction, *args, **kwargs) -> None:
async def invoke(self, inter: ApplicationCommandInteraction, *args: Any, **kwargs: Any) -> None:
for k, v in self.connectors.items():
if k in kwargs:
kwargs[v] = kwargs.pop(k)
Expand Down Expand Up @@ -439,7 +439,7 @@ def __init__(
guild_ids: Optional[Sequence[int]] = None,
connectors: Optional[Dict[str, str]] = None,
auto_sync: Optional[bool] = None,
**kwargs,
**kwargs: Any,
) -> None:
name_loc = Localized._cast(name, False)
super().__init__(func, name=name_loc.string, **kwargs)
Expand Down Expand Up @@ -525,7 +525,7 @@ def sub_command(
options: Optional[list] = None,
connectors: Optional[dict] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[CommandCallback], SubCommand]:
"""A decorator that creates a subcommand under the base command.
Expand Down Expand Up @@ -587,7 +587,7 @@ def sub_command_group(
self,
name: LocalizedOptional = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[CommandCallback], SubCommandGroup]:
"""A decorator that creates a subcommand group under the base command.
Expand Down Expand Up @@ -758,7 +758,7 @@ def slash_command(
connectors: Optional[Dict[str, str]] = None,
auto_sync: Optional[bool] = None,
extras: Optional[Dict[str, Any]] = None,
**kwargs,
**kwargs: Any,
) -> Callable[[CommandCallback], InvokableSlashCommand]:
"""A decorator that builds a slash command.
Expand Down
2 changes: 1 addition & 1 deletion disnake/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,7 @@ def edit_guild_welcome_screen(
guild_id: Snowflake,
*,
reason: Optional[str] = None,
**kwargs,
**kwargs: Any,
) -> Response[welcome_screen.WelcomeScreen]:
valid_keys = (
"enabled",
Expand Down
2 changes: 1 addition & 1 deletion disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ async def create_thread(
return Thread(guild=self.guild, state=self._state, data=data)

async def reply(
self, content: Optional[str] = None, *, fail_if_not_exists: bool = True, **kwargs
self, content: Optional[str] = None, *, fail_if_not_exists: bool = True, **kwargs: Any
) -> Message:
"""|coro|
Expand Down

0 comments on commit 985d8a9

Please sign in to comment.