diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f148629a..d79d7e743 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,13 +29,13 @@ repos: name: TOML Structure - id: check-merge-conflict name: Merge Conflicts - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.272' + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.0.278' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black name: Black Formatting diff --git a/interactions/api/http/http_requests/threads.py b/interactions/api/http/http_requests/threads.py index f2c9935f6..0f23a0ccd 100644 --- a/interactions/api/http/http_requests/threads.py +++ b/interactions/api/http/http_requests/threads.py @@ -81,7 +81,7 @@ async def list_thread_members(self, thread_id: "Snowflake_Type") -> List[discord async def list_public_archived_threads( self, channel_id: "Snowflake_Type", - limit: int = None, + limit: int | None = None, before: Optional["Snowflake_Type"] = None, ) -> discord_typings.ListThreadsData: """ @@ -108,7 +108,7 @@ async def list_public_archived_threads( async def list_private_archived_threads( self, channel_id: "Snowflake_Type", - limit: int = None, + limit: int | None = None, before: Optional["Snowflake_Type"] = None, ) -> discord_typings.ListThreadsData: """ @@ -135,7 +135,7 @@ async def list_private_archived_threads( async def list_joined_private_archived_threads( self, channel_id: "Snowflake_Type", - limit: int = None, + limit: int | None = None, before: Optional["Snowflake_Type"] = None, ) -> discord_typings.ListThreadsData: """ @@ -229,7 +229,7 @@ async def create_forum_thread( name: str, auto_archive_duration: int, message: dict | FormData, - applied_tags: List[str] = None, + applied_tags: List[str] | None = None, rate_limit_per_user: Absent[int] = MISSING, files: Absent["UPLOADABLE_TYPE"] = MISSING, reason: Absent[str] = MISSING, diff --git a/interactions/api/http/http_requests/users.py b/interactions/api/http/http_requests/users.py index f601f3da9..73519cf10 100644 --- a/interactions/api/http/http_requests/users.py +++ b/interactions/api/http/http_requests/users.py @@ -100,7 +100,7 @@ async def group_dm_add_recipient( channel_id: "Snowflake_Type", user_id: "Snowflake_Type", access_token: str, - nick: str = None, + nick: str | None = None, ) -> None: """ Adds a recipient to a Group DM using their access token. @@ -130,7 +130,7 @@ async def group_dm_remove_recipient(self, channel_id: "Snowflake_Type", user_id: Route("DELETE", "/channels/{channel_id}/recipients/{user_id}", channel_id=channel_id, user_id=user_id) ) - async def modify_current_user_nick(self, guild_id: "Snowflake_Type", nickname: str = None) -> None: + async def modify_current_user_nick(self, guild_id: "Snowflake_Type", nickname: str | None = None) -> None: """ Modifies the nickname of the current user in a guild. diff --git a/interactions/api/http/http_requests/webhooks.py b/interactions/api/http/http_requests/webhooks.py index cf1a97889..f5b372c1c 100644 --- a/interactions/api/http/http_requests/webhooks.py +++ b/interactions/api/http/http_requests/webhooks.py @@ -59,7 +59,9 @@ async def get_guild_webhooks(self, guild_id: "Snowflake_Type") -> List[discord_t """ return await self.request(Route("GET", "/guilds/{guild_id}/webhooks", guild_id=guild_id)) - async def get_webhook(self, webhook_id: "Snowflake_Type", webhook_token: str = None) -> discord_typings.WebhookData: + async def get_webhook( + self, webhook_id: "Snowflake_Type", webhook_token: str | None = None + ) -> discord_typings.WebhookData: """ Return the new webhook object for the given id. @@ -81,7 +83,7 @@ async def modify_webhook( name: str, avatar: Any, channel_id: "Snowflake_Type", - webhook_token: str = None, + webhook_token: str | None = None, ) -> discord_typings.WebhookData: """ Modify a webhook. @@ -101,7 +103,7 @@ async def modify_webhook( payload={"name": name, "avatar": avatar, "channel_id": channel_id}, ) - async def delete_webhook(self, webhook_id: "Snowflake_Type", webhook_token: str = None) -> None: + async def delete_webhook(self, webhook_id: "Snowflake_Type", webhook_token: str | None = None) -> None: """ Delete a webhook. diff --git a/interactions/api/voice/recorder.py b/interactions/api/voice/recorder.py index 3939e718a..6ae3c51ea 100644 --- a/interactions/api/voice/recorder.py +++ b/interactions/api/voice/recorder.py @@ -29,7 +29,7 @@ class Recorder(threading.Thread): - def __init__(self, v_state, loop, *, output_dir: str = None) -> None: + def __init__(self, v_state, loop, *, output_dir: str | None = None) -> None: super().__init__() self.daemon = True diff --git a/interactions/client/client.py b/interactions/client/client.py index 4a029deb8..ff1d5383f 100644 --- a/interactions/client/client.py +++ b/interactions/client/client.py @@ -1111,7 +1111,7 @@ async def wait_for_component( dict, ] ] = None, - check: Absent[Optional[Union[Callable[..., bool], Callable[..., Awaitable[bool]]]]] = None, + check: Absent[Optional[Union[Callable[..., bool], Callable[..., Awaitable[bool]]]]] | None = None, timeout: Optional[float] = None, ) -> "events.Component": """ diff --git a/interactions/ext/hybrid_commands/hybrid_slash.py b/interactions/ext/hybrid_commands/hybrid_slash.py index 6f998b9df..98485c625 100644 --- a/interactions/ext/hybrid_commands/hybrid_slash.py +++ b/interactions/ext/hybrid_commands/hybrid_slash.py @@ -239,7 +239,7 @@ async def __call__(self, context: SlashContext, *args, **kwargs) -> None: def group( self, - name: str = None, + name: str | None = None, description: str = "No Description Set", inherit_checks: bool = True, aliases: list[str] | None = None, @@ -263,7 +263,7 @@ def subcommand( group_name: LocalisedName | str = None, sub_cmd_description: Absent[LocalisedDesc | str] = MISSING, group_description: Absent[LocalisedDesc | str] = MISSING, - options: List[Union[SlashCommandOption, dict]] = None, + options: List[Union[SlashCommandOption, dict]] | None = None, nsfw: bool = False, inherit_checks: bool = True, aliases: list[str] | None = None, @@ -541,8 +541,8 @@ def hybrid_slash_subcommand( base_dm_permission: bool = True, subcommand_group_description: Optional[str | LocalisedDesc] = None, sub_group_desc: Optional[str | LocalisedDesc] = None, - scopes: List["Snowflake_Type"] = None, - options: List[dict] = None, + scopes: List["Snowflake_Type"] | None = None, + options: List[dict] | None = None, nsfw: bool = False, silence_autocomplete_errors: bool = False, ) -> Callable[[AsyncCallable], HybridSlashCommand]: diff --git a/interactions/ext/prefixed_commands/command.py b/interactions/ext/prefixed_commands/command.py index f8aca4fd2..73c0c7ea7 100644 --- a/interactions/ext/prefixed_commands/command.py +++ b/interactions/ext/prefixed_commands/command.py @@ -92,7 +92,7 @@ def __init__( self, name: str, default: Any = MISSING, - type: Type = None, + type: Type | None = None, kind: inspect._ParameterKind = inspect._ParameterKind.POSITIONAL_OR_KEYWORD, converters: Optional[list[Callable[["PrefixedContext", str], Any]]] = None, greedy: bool = False, diff --git a/interactions/ext/sentry.py b/interactions/ext/sentry.py index 6b334516e..821899927 100644 --- a/interactions/ext/sentry.py +++ b/interactions/ext/sentry.py @@ -89,7 +89,7 @@ def on_error_sentry_hook(self: Task, error: Exception) -> None: def setup( bot: Client, - token: str = None, + token: str | None = None, filter: Optional[Callable[[dict[str, Any], dict[str, Any]], Optional[dict[str, Any]]]] = None, **kwargs, ) -> None: diff --git a/interactions/models/discord/channel.py b/interactions/models/discord/channel.py index f35e228c6..2638d4a6b 100644 --- a/interactions/models/discord/channel.py +++ b/interactions/models/discord/channel.py @@ -391,7 +391,7 @@ async def delete_messages( else: await self._client.http.bulk_delete_messages(self.id, message_ids, reason) - async def delete_message(self, message: Union[Snowflake_Type, "models.Message"], reason: str = None) -> None: + async def delete_message(self, message: Union[Snowflake_Type, "models.Message"], reason: str | None = None) -> None: """ Delete a single message from a channel. @@ -565,7 +565,7 @@ async def create_thread( invitable: Absent[bool] = MISSING, rate_limit_per_user: Absent[int] = MISSING, auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY, - reason: Absent[str] = None, + reason: Absent[str] | None = None, ) -> "TYPE_THREAD_CHANNEL": """ Creates a new thread in this channel. If a message is provided, it will be used as the initial message. @@ -605,7 +605,7 @@ async def create_thread( return self._client.cache.place_channel_data(thread_data) async def fetch_public_archived_threads( - self, limit: int = None, before: Optional["models.Timestamp"] = None + self, limit: int | None = None, before: Optional["models.Timestamp"] = None ) -> "models.ThreadList": """ Get a `ThreadList` of archived **public** threads available in this channel. @@ -625,7 +625,7 @@ async def fetch_public_archived_threads( return models.ThreadList.from_dict(threads_data, self._client) async def fetch_private_archived_threads( - self, limit: int = None, before: Optional["models.Timestamp"] = None + self, limit: int | None = None, before: Optional["models.Timestamp"] = None ) -> "models.ThreadList": """ Get a `ThreadList` of archived **private** threads available in this channel. @@ -645,7 +645,7 @@ async def fetch_private_archived_threads( return models.ThreadList.from_dict(threads_data, self._client) async def fetch_archived_threads( - self, limit: int = None, before: Optional["models.Timestamp"] = None + self, limit: int | None = None, before: Optional["models.Timestamp"] = None ) -> "models.ThreadList": """ Get a `ThreadList` of archived threads available in this channel. @@ -668,7 +668,7 @@ async def fetch_archived_threads( return models.ThreadList.from_dict(threads_data, self._client) async def fetch_joined_private_archived_threads( - self, limit: int = None, before: Optional["models.Timestamp"] = None + self, limit: int | None = None, before: Optional["models.Timestamp"] = None ) -> "models.ThreadList": """ Get a `ThreadList` of threads the bot is a participant of in this channel. @@ -1224,7 +1224,7 @@ async def set_permission( view_audit_log: bool | None = None, view_channel: bool | None = None, view_guild_insights: bool | None = None, - reason: str = None, + reason: str | None = None, ) -> None: """ Set the Permission Overwrites for a given target. @@ -1668,7 +1668,7 @@ async def create_thread_from_message( name: str, message: Snowflake_Type, auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY, - reason: Absent[str] = None, + reason: Absent[str] | None = None, ) -> "GuildNewsThread": """ Creates a new news thread in this channel. @@ -1751,7 +1751,7 @@ async def create_public_thread( name: str, auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY, rate_limit_per_user: Absent[int] = MISSING, - reason: Absent[str] = None, + reason: Absent[str] | None = None, ) -> "GuildPublicThread": """ Creates a new public thread in this channel. @@ -1780,7 +1780,7 @@ async def create_private_thread( invitable: Absent[bool] = MISSING, auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY, rate_limit_per_user: Absent[int] = MISSING, - reason: Absent[str] = None, + reason: Absent[str] | None = None, ) -> "GuildPrivateThread": """ Creates a new private thread in this channel. @@ -1810,7 +1810,7 @@ async def create_thread_from_message( name: str, message: Snowflake_Type, auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY, - reason: Absent[str] = None, + reason: Absent[str] | None = None, ) -> "GuildPublicThread": """ Creates a new public thread in this channel. diff --git a/interactions/models/discord/components.py b/interactions/models/discord/components.py index 0cc3accd2..632089b5e 100644 --- a/interactions/models/discord/components.py +++ b/interactions/models/discord/components.py @@ -212,7 +212,7 @@ def __init__( style: ButtonStyle | int, label: str | None = None, emoji: "PartialEmoji | None | str" = None, - custom_id: str = None, + custom_id: str | None = None, url: str | None = None, disabled: bool = False, ) -> None: diff --git a/interactions/models/discord/guild.py b/interactions/models/discord/guild.py index 1f5dbf86b..325f6655d 100644 --- a/interactions/models/discord/guild.py +++ b/interactions/models/discord/guild.py @@ -1221,7 +1221,7 @@ async def create_category( ) async def delete_channel( - self, channel: Union["models.TYPE_GUILD_CHANNEL", Snowflake_Type], reason: str = None + self, channel: Union["models.TYPE_GUILD_CHANNEL", Snowflake_Type], reason: str | None = None ) -> None: """ Delete the given channel, can handle either a snowflake or channel object. @@ -1875,7 +1875,7 @@ async def unban( """ await self._client.http.remove_guild_ban(self.id, to_snowflake(user), reason=reason) - async def fetch_widget_image(self, style: str = None) -> str: + async def fetch_widget_image(self, style: str | None = None) -> str: """ Fetch a guilds widget image. diff --git a/interactions/models/discord/webhooks.py b/interactions/models/discord/webhooks.py index 4fda39f99..4d88f8534 100644 --- a/interactions/models/discord/webhooks.py +++ b/interactions/models/discord/webhooks.py @@ -189,8 +189,8 @@ async def send( tts: bool = False, suppress_embeds: bool = False, flags: Optional[Union[int, "MessageFlags"]] = None, - username: str = None, - avatar_url: str = None, + username: str | None = None, + avatar_url: str | None = None, wait: bool = False, thread: "Snowflake_Type" = None, **kwargs, diff --git a/interactions/models/internal/annotations/slash.py b/interactions/models/internal/annotations/slash.py index 6d0825638..8e156737f 100644 --- a/interactions/models/internal/annotations/slash.py +++ b/interactions/models/internal/annotations/slash.py @@ -32,7 +32,7 @@ def slash_str_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, min_length: Optional[int] = None, max_length: Optional[int] = None, ) -> Type[str]: @@ -64,7 +64,7 @@ def slash_float_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, min_value: Optional[float] = None, max_value: Optional[float] = None, ) -> Type[float]: @@ -96,7 +96,7 @@ def slash_int_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, min_value: Optional[float] = None, max_value: Optional[float] = None, ) -> Type[int]: @@ -171,7 +171,7 @@ def slash_channel_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, channel_types: Optional[list[Union["ChannelType", int]]] = None, ) -> Type["BaseChannel"]: """ @@ -200,7 +200,7 @@ def slash_role_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, ) -> Type["Role"]: """ Annotates an argument as a role type slash command option. @@ -226,7 +226,7 @@ def slash_mentionable_option( description: str, required: bool = False, autocomplete: bool = False, - choices: List[Union["SlashCommandChoice", dict]] = None, + choices: List[Union["SlashCommandChoice", dict]] | None = None, ) -> Type[Union["Role", "BaseChannel", "User", "Member"]]: """ Annotates an argument as a mentionable type slash command option. diff --git a/interactions/models/internal/application_commands.py b/interactions/models/internal/application_commands.py index e89aa1ae0..763bbefff 100644 --- a/interactions/models/internal/application_commands.py +++ b/interactions/models/internal/application_commands.py @@ -717,7 +717,7 @@ def wrapper(call: Callable[..., Coroutine]) -> Callable[..., Coroutine]: return wrapper def group( - self, name: str = None, description: str = "No Description Set", inherit_checks: bool = True + self, name: str | None = None, description: str = "No Description Set", inherit_checks: bool = True ) -> "SlashCommand": return SlashCommand( name=self.name, @@ -736,7 +736,7 @@ def subcommand( group_name: LocalisedName | str = None, sub_cmd_description: Absent[LocalisedDesc | str] = MISSING, group_description: Absent[LocalisedDesc | str] = MISSING, - options: List[Union[SlashCommandOption, Dict]] = None, + options: List[Union[SlashCommandOption, Dict]] | None = None, nsfw: bool = False, inherit_checks: bool = True, ) -> Callable[..., "SlashCommand"]: @@ -961,8 +961,8 @@ def subcommand( base_dm_permission: bool = True, subcommand_group_description: Optional[str | LocalisedDesc] = None, sub_group_desc: Optional[str | LocalisedDesc] = None, - scopes: List["Snowflake_Type"] = None, - options: List[dict] = None, + scopes: List["Snowflake_Type"] | None = None, + options: List[dict] | None = None, nsfw: bool = False, ) -> Callable[[AsyncCallable], SlashCommand]: """ @@ -1190,7 +1190,7 @@ def slash_option( opt_type: Union[OptionType, int], required: bool = False, autocomplete: bool = False, - choices: List[Union[SlashCommandChoice, dict]] = None, + choices: List[Union[SlashCommandChoice, dict]] | None = None, channel_types: Optional[list[Union[ChannelType, int]]] = None, min_value: Optional[float] = None, max_value: Optional[float] = None,