From 187261509c6df34518e51b3c5842a29f61d3045f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=85=BC=E5=AE=B9=20Pydantic=20V2?= =?UTF-8?q?=20(#34)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 💥 移除 python3.8 支持 * ✨ 兼容 Pydantic V2 * :rotating_light: auto fix by pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- nonebot/adapters/discord/adapter.py | 8 +- nonebot/adapters/discord/api/handle.py | 148 +++-- nonebot/adapters/discord/api/model.py | 597 +++++++++---------- nonebot/adapters/discord/api/types.py | 26 +- nonebot/adapters/discord/api/utils.py | 30 +- nonebot/adapters/discord/commands/matcher.py | 33 +- nonebot/adapters/discord/commands/params.py | 6 +- nonebot/adapters/discord/commands/storage.py | 8 +- nonebot/adapters/discord/config.py | 8 +- nonebot/adapters/discord/event.py | 6 +- nonebot/adapters/discord/message.py | 10 +- nonebot/adapters/discord/payload.py | 6 +- nonebot/adapters/discord/utils.py | 8 +- poetry.lock | 10 +- pyproject.toml | 4 +- 15 files changed, 458 insertions(+), 450 deletions(-) diff --git a/nonebot/adapters/discord/adapter.py b/nonebot/adapters/discord/adapter.py index 7ad91d7..728ab90 100644 --- a/nonebot/adapters/discord/adapter.py +++ b/nonebot/adapters/discord/adapter.py @@ -2,7 +2,7 @@ import contextlib import json import sys -from typing import Any, List, Optional, Tuple +from typing import Any, Optional from typing_extensions import override from nonebot.adapters import Adapter as BaseAdapter @@ -41,7 +41,7 @@ class Adapter(BaseAdapter): def __init__(self, driver: Driver, **kwargs: Any): super().__init__(driver, **kwargs) self.discord_config: Config = get_plugin_config(Config) - self.tasks: List[asyncio.Task] = [] + self.tasks: list[asyncio.Task] = [] self.base_url: URL = URL( f"https://discord.com/api/v{self.discord_config.discord_api_version}", ) @@ -151,7 +151,7 @@ async def _forward_ws( self, bot_info: BotInfo, ws_url: URL, - shard: Tuple[int, int], + shard: tuple[int, int], ) -> None: log("DEBUG", f"Forwarding WebSocket Connection to {escape_tag(str(ws_url))}...") headers = {"Authorization": self.get_authorization(bot_info)} @@ -288,7 +288,7 @@ async def _heartbeat_task(self, ws: WebSocket, bot: Bot, heartbeat_interval: int await self._heartbeat(ws, bot) await asyncio.sleep(heartbeat_interval / 1000.0) - async def _authenticate(self, bot: Bot, ws: WebSocket, shard: Tuple[int, int]): + async def _authenticate(self, bot: Bot, ws: WebSocket, shard: tuple[int, int]): """鉴权连接""" if not bot.ready: payload = type_validate_python( diff --git a/nonebot/adapters/discord/api/handle.py b/nonebot/adapters/discord/api/handle.py index 7376d9f..a9c21ed 100644 --- a/nonebot/adapters/discord/api/handle.py +++ b/nonebot/adapters/discord/api/handle.py @@ -1,10 +1,8 @@ +from collections.abc import Awaitable from typing import ( TYPE_CHECKING, Any, - Awaitable, Callable, - Dict, - List, Literal, Optional, ) @@ -29,7 +27,7 @@ async def _get_global_application_commands( adapter: "Adapter", bot: "Bot", application_id: SnowflakeType, **params -) -> List[ApplicationCommand]: +) -> list[ApplicationCommand]: """Fetch a global command for your application. Returns an application command object. @@ -43,7 +41,7 @@ async def _get_global_application_commands( params=params, ) return type_validate_python( - List[ApplicationCommand], await _request(adapter, bot, request) + list[ApplicationCommand], await _request(adapter, bot, request) ) @@ -139,8 +137,8 @@ async def _bulk_overwrite_global_application_commands( adapter: "Adapter", bot: "Bot", application_id: SnowflakeType, - commands: List[ApplicationCommandCreate], -) -> List[ApplicationCommand]: + commands: list[ApplicationCommandCreate], +) -> list[ApplicationCommand]: """Takes a list of application commands, overwriting the existing global command list for this application. Returns 200 and a list of application command objects. @@ -157,7 +155,7 @@ async def _bulk_overwrite_global_application_commands( json=[model_dump(command, exclude_unset=True) for command in commands], ) return type_validate_python( - List[ApplicationCommand], await _request(adapter, bot, request) + list[ApplicationCommand], await _request(adapter, bot, request) ) @@ -167,7 +165,7 @@ async def _get_guild_application_commands( application_id: SnowflakeType, guild_id: SnowflakeType, **params, -) -> List[ApplicationCommand]: +) -> list[ApplicationCommand]: """Fetch all of the guild commands for your application for a specific guild. Returns an array of application command objects. @@ -182,7 +180,7 @@ async def _get_guild_application_commands( params=params, ) return type_validate_python( - List[ApplicationCommand], await _request(adapter, bot, request) + list[ApplicationCommand], await _request(adapter, bot, request) ) @@ -293,8 +291,8 @@ async def _bulk_overwrite_guild_application_commands( bot: "Bot", application_id: SnowflakeType, guild_id: SnowflakeType, - commands: List[ApplicationCommandCreate], -) -> List[ApplicationCommand]: + commands: list[ApplicationCommandCreate], +) -> list[ApplicationCommand]: """Takes a list of application commands, overwriting the existing command list for this application for the targeted guild. Returns 200 and a list of application command objects. @@ -310,7 +308,7 @@ async def _bulk_overwrite_guild_application_commands( json=[model_dump(command, exclude_unset=True) for command in commands], ) return type_validate_python( - List[ApplicationCommand], await _request(adapter, bot, request) + list[ApplicationCommand], await _request(adapter, bot, request) ) @@ -319,7 +317,7 @@ async def _get_guild_application_command_permissions( bot: "Bot", application_id: SnowflakeType, guild_id: SnowflakeType, -) -> List[GuildApplicationCommandPermissions]: +) -> list[GuildApplicationCommandPermissions]: """ Fetches permissions for all commands for your application in a guild. Returns an array of guild application command permissions objects. @@ -334,7 +332,7 @@ async def _get_guild_application_command_permissions( / f"applications/{application_id}/guilds/{guild_id}/commands/permissions", ) return type_validate_python( - List[GuildApplicationCommandPermissions], await _request(adapter, bot, request) + list[GuildApplicationCommandPermissions], await _request(adapter, bot, request) ) @@ -369,7 +367,7 @@ async def _edit_application_command_permissions( application_id: SnowflakeType, guild_id: SnowflakeType, command_id: SnowflakeType, - permissions: List[ApplicationCommandPermissions], + permissions: list[ApplicationCommandPermissions], ) -> GuildApplicationCommandPermissions: """ Edits command permissions for a specific command for your application in a guild @@ -573,7 +571,7 @@ async def _get_current_application( async def _get_application_role_connection_metadata_records( adapter: "Adapter", bot: "Bot", application_id: SnowflakeType -) -> List[ApplicationRoleConnectionMetadata]: +) -> list[ApplicationRoleConnectionMetadata]: """get application role connection metadata records see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records @@ -586,13 +584,13 @@ async def _get_application_role_connection_metadata_records( / f"applications/{application_id}/role-connections/metadata", ) return type_validate_python( - List[ApplicationRoleConnectionMetadata], await _request(adapter, bot, request) + list[ApplicationRoleConnectionMetadata], await _request(adapter, bot, request) ) async def _update_application_role_connection_metadata_records( adapter: "Adapter", bot: "Bot", application_id: SnowflakeType -) -> List[ApplicationRoleConnectionMetadata]: +) -> list[ApplicationRoleConnectionMetadata]: """get application role connection metadata records see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records @@ -605,7 +603,7 @@ async def _update_application_role_connection_metadata_records( / f"applications/{application_id}/role-connections/metadata", ) return type_validate_python( - List[ApplicationRoleConnectionMetadata], await _request(adapter, bot, request) + list[ApplicationRoleConnectionMetadata], await _request(adapter, bot, request) ) @@ -627,7 +625,7 @@ async def _get_guild_audit_log( async def _list_auto_moderation_rules_for_guild( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[AutoModerationRule]: +) -> list[AutoModerationRule]: """list auto moderation rules for guild see https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild @@ -639,7 +637,7 @@ async def _list_auto_moderation_rules_for_guild( url=adapter.base_url / f"guilds/{guild_id}/auto-moderation/rules", ) return type_validate_python( - List[AutoModerationRule], await _request(adapter, bot, request) + list[AutoModerationRule], await _request(adapter, bot, request) ) @@ -831,7 +829,7 @@ async def _delete_channel( async def _get_channel_messages( adapter: "Adapter", bot: "Bot", channel_id: SnowflakeType, **data -) -> List[MessageGet]: +) -> list[MessageGet]: """get channel messages see https://discord.com/developers/docs/resources/channel#get-channel-messages""" @@ -842,7 +840,7 @@ async def _get_channel_messages( url=adapter.base_url / f"channels/{channel_id}/messages", params=data, ) - return type_validate_python(List[MessageGet], await _request(adapter, bot, request)) + return type_validate_python(list[MessageGet], await _request(adapter, bot, request)) async def _get_channel_message( @@ -971,7 +969,7 @@ async def _get_reactions( emoji: str, emoji_id: Optional[SnowflakeType] = None, **params, -) -> List[User]: +) -> list[User]: """get reactions see https://discord.com/developers/docs/resources/channel#get-reactions""" @@ -985,7 +983,7 @@ async def _get_reactions( / f"channels/{channel_id}/messages/{message_id}/reactions/{quote(emoji)}", params=params, ) - return type_validate_python(List[User], await _request(adapter, bot, request)) + return type_validate_python(list[User], await _request(adapter, bot, request)) async def _delete_all_reactions( @@ -1106,7 +1104,7 @@ async def _edit_channel_permissions( async def _get_channel_invites( adapter: "Adapter", bot: "Bot", channel_id: SnowflakeType -) -> List[Invite]: +) -> list[Invite]: """https://discord.com/developers/docs/resources/channel#get-channel-invites""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1114,7 +1112,7 @@ async def _get_channel_invites( method="GET", url=adapter.base_url / f"channels/{channel_id}/invites", ) - return type_validate_python(List[Invite], await _request(adapter, bot, request)) + return type_validate_python(list[Invite], await _request(adapter, bot, request)) async def _create_channel_invite( @@ -1181,7 +1179,7 @@ async def _trigger_typing_indicator( async def _get_pinned_messages( adapter: "Adapter", bot: "Bot", channel_id: SnowflakeType -) -> List[MessageGet]: +) -> list[MessageGet]: """https://discord.com/developers/docs/resources/channel#get-pinned-messages""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1189,7 +1187,7 @@ async def _get_pinned_messages( method="GET", url=adapter.base_url / f"channels/{channel_id}/pins", ) - return type_validate_python(List[MessageGet], await _request(adapter, bot, request)) + return type_validate_python(list[MessageGet], await _request(adapter, bot, request)) async def _pin_message( @@ -1382,7 +1380,7 @@ async def _get_thread_member( async def _list_thread_members( adapter: "Adapter", bot: "Bot", channel_id: SnowflakeType, **params -) -> List[ThreadMember]: +) -> list[ThreadMember]: """https://discord.com/developers/docs/resources/channel#list-thread-members""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1392,7 +1390,7 @@ async def _list_thread_members( params=params, ) return type_validate_python( - List[ThreadMember], await _request(adapter, bot, request) + list[ThreadMember], await _request(adapter, bot, request) ) @@ -1453,7 +1451,7 @@ async def _list_joined_private_archived_threads( async def _list_guild_emojis( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Emoji]: +) -> list[Emoji]: """https://discord.com/developers/docs/resources/emoji#list-guild-emojis""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1461,7 +1459,7 @@ async def _list_guild_emojis( method="GET", url=adapter.base_url / f"guilds/{guild_id}/emojis", ) - return type_validate_python(List[Emoji], await _request(adapter, bot, request)) + return type_validate_python(list[Emoji], await _request(adapter, bot, request)) async def _get_guild_emoji( @@ -1601,7 +1599,7 @@ async def _delete_guild( async def _get_guild_channels( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Channel]: +) -> list[Channel]: """https://discord.com/developers/docs/resources/guild#get-guild-channels""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1609,7 +1607,7 @@ async def _get_guild_channels( method="GET", url=adapter.base_url / f"guilds/{guild_id}/channels", ) - return type_validate_python(List[Channel], await _request(adapter, bot, request)) + return type_validate_python(list[Channel], await _request(adapter, bot, request)) async def _create_guild_channel( @@ -1675,7 +1673,7 @@ async def _get_guild_member( async def _list_guild_members( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **params -) -> List[GuildMember]: +) -> list[GuildMember]: """https://discord.com/developers/docs/resources/guild#list-guild-members""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1685,13 +1683,13 @@ async def _list_guild_members( params=params, ) return type_validate_python( - List[GuildMember], await _request(adapter, bot, request) + list[GuildMember], await _request(adapter, bot, request) ) async def _search_guild_members( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **params -) -> List[GuildMember]: +) -> list[GuildMember]: """https://discord.com/developers/docs/resources/guild#search-guild-members""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1701,7 +1699,7 @@ async def _search_guild_members( params=params, ) return type_validate_python( - List[GuildMember], await _request(adapter, bot, request) + list[GuildMember], await _request(adapter, bot, request) ) @@ -1836,7 +1834,7 @@ async def _remove_guild_member( async def _get_guild_bans( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **params -) -> List[Ban]: +) -> list[Ban]: """https://discord.com/developers/docs/resources/guild#get-guild-bans""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1845,7 +1843,7 @@ async def _get_guild_bans( url=adapter.base_url / f"guilds/{guild_id}/bans", params=params, ) - return type_validate_python(List[Ban], await _request(adapter, bot, request)) + return type_validate_python(list[Ban], await _request(adapter, bot, request)) async def _get_guild_ban( @@ -1902,7 +1900,7 @@ async def _remove_guild_ban( async def _get_guild_roles( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Role]: +) -> list[Role]: """https://discord.com/developers/docs/resources/guild#get-guild-roles""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -1910,7 +1908,7 @@ async def _get_guild_roles( method="GET", url=adapter.base_url / f"guilds/{guild_id}/roles", ) - return type_validate_python(List[Role], await _request(adapter, bot, request)) + return type_validate_python(list[Role], await _request(adapter, bot, request)) async def _create_guild_role( @@ -1931,7 +1929,7 @@ async def _create_guild_role( async def _modify_guild_role_positions( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **data -) -> List[Role]: +) -> list[Role]: """https://discord.com/developers/docs/resources/guild#modify-guild-role-positions""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} if data.get("reason"): @@ -1942,7 +1940,7 @@ async def _modify_guild_role_positions( url=adapter.base_url / f"guilds/{guild_id}/roles", json=data, ) - return type_validate_python(List[Role], await _request(adapter, bot, request)) + return type_validate_python(list[Role], await _request(adapter, bot, request)) async def _modify_guild_role( @@ -2002,7 +2000,7 @@ async def _delete_guild_role( async def _get_guild_prune_count( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **data -) -> Dict[Literal["pruned"], int]: +) -> dict[Literal["pruned"], int]: """https://discord.com/developers/docs/resources/guild#get-guild-prune-count""" if "include_roles" in data: data["include_roles"] = ",".join(str(role) for role in data["include_roles"]) @@ -2018,7 +2016,7 @@ async def _get_guild_prune_count( async def _begin_guild_prune( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **data -) -> Dict[Literal["pruned"], int]: +) -> dict[Literal["pruned"], int]: """https://discord.com/developers/docs/resources/guild#begin-guild-prune""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} if data.get("reason"): @@ -2034,7 +2032,7 @@ async def _begin_guild_prune( async def _get_guild_voice_regions( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[VoiceRegion]: +) -> list[VoiceRegion]: """https://discord.com/developers/docs/resources/guild#get-guild-voice-regions""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2043,13 +2041,13 @@ async def _get_guild_voice_regions( url=adapter.base_url / f"guilds/{guild_id}/regions", ) return type_validate_python( - List[VoiceRegion], await _request(adapter, bot, request) + list[VoiceRegion], await _request(adapter, bot, request) ) async def _get_guild_invites( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Invite]: +) -> list[Invite]: """https://discord.com/developers/docs/resources/guild#get-guild-invites""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2057,12 +2055,12 @@ async def _get_guild_invites( method="GET", url=adapter.base_url / f"guilds/{guild_id}/invites", ) - return type_validate_python(List[Invite], await _request(adapter, bot, request)) + return type_validate_python(list[Invite], await _request(adapter, bot, request)) async def _get_guild_integrations( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Integration]: +) -> list[Integration]: """https://discord.com/developers/docs/resources/guild#get-guild-integrations""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2071,7 +2069,7 @@ async def _get_guild_integrations( url=adapter.base_url / f"guilds/{guild_id}/integrations", ) return type_validate_python( - List[Integration], await _request(adapter, bot, request) + list[Integration], await _request(adapter, bot, request) ) @@ -2244,7 +2242,7 @@ async def _modify_user_voice_state( async def _list_scheduled_events_for_guild( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType, **params -) -> List[GuildScheduledEvent]: +) -> list[GuildScheduledEvent]: """https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2254,7 +2252,7 @@ async def _list_scheduled_events_for_guild( params=params, ) return type_validate_python( - List[GuildScheduledEvent], await _request(adapter, bot, request) + list[GuildScheduledEvent], await _request(adapter, bot, request) ) @@ -2343,7 +2341,7 @@ async def _get_guild_scheduled_event_users( guild_id: SnowflakeType, event_id: SnowflakeType, **params, -) -> List[GuildScheduledEventUser]: +) -> list[GuildScheduledEventUser]: """https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2353,7 +2351,7 @@ async def _get_guild_scheduled_event_users( params=params, ) return type_validate_python( - List[GuildScheduledEventUser], await _request(adapter, bot, request) + list[GuildScheduledEventUser], await _request(adapter, bot, request) ) @@ -2386,7 +2384,7 @@ async def _create_guild_from_guild_template( async def _get_guild_templates( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[GuildTemplate]: +) -> list[GuildTemplate]: """https://discord.com/developers/docs/resources/guild-template#get-guild-templates""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2395,7 +2393,7 @@ async def _get_guild_templates( url=adapter.base_url / f"guilds/{guild_id}/templates", ) return type_validate_python( - List[GuildTemplate], await _request(adapter, bot, request) + list[GuildTemplate], await _request(adapter, bot, request) ) @@ -2563,7 +2561,7 @@ async def _get_sticker( async def _list_nitro_sticker_packs( adapter: "Adapter", bot: "Bot" -) -> List[StickerPack]: +) -> list[StickerPack]: """https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2572,13 +2570,13 @@ async def _list_nitro_sticker_packs( url=adapter.base_url / "sticker-packs", ) return type_validate_python( - List[StickerPack], await _request(adapter, bot, request) + list[StickerPack], await _request(adapter, bot, request) ) async def _list_guild_stickers( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Sticker]: +) -> list[Sticker]: """https://discord.com/developers/docs/resources/sticker#list-guild-stickers""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2586,7 +2584,7 @@ async def _list_guild_stickers( method="GET", url=adapter.base_url / f"guilds/{guild_id}/stickers", ) - return type_validate_python(List[Sticker], await _request(adapter, bot, request)) + return type_validate_python(list[Sticker], await _request(adapter, bot, request)) async def _get_guild_sticker( @@ -2706,7 +2704,7 @@ async def _modify_current_user(adapter: "Adapter", bot: "Bot", **data) -> User: async def _get_current_user_guilds( adapter: "Adapter", bot: "Bot", **params -) -> List[CurrentUserGuild]: +) -> list[CurrentUserGuild]: """https://discord.com/developers/docs/resources/user#get-current-user-guilds""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2716,7 +2714,7 @@ async def _get_current_user_guilds( params=params, ) return type_validate_python( - List[CurrentUserGuild], await _request(adapter, bot, request) + list[CurrentUserGuild], await _request(adapter, bot, request) ) @@ -2771,7 +2769,7 @@ async def _create_group_DM(adapter: "Adapter", bot: "Bot", **data) -> Channel: async def _get_user_connections( adapter: "Adapter", bot: "Bot", -) -> List[Connection]: +) -> list[Connection]: """https://discord.com/developers/docs/resources/user#get-user-connections""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2779,7 +2777,7 @@ async def _get_user_connections( method="GET", url=adapter.base_url / "users/@me/connections", ) - return type_validate_python(List[Connection], await _request(adapter, bot, request)) + return type_validate_python(list[Connection], await _request(adapter, bot, request)) async def _get_user_application_role_connection( @@ -2819,7 +2817,7 @@ async def _update_user_application_role_connection( ) -async def _list_voice_regions(adapter: "Adapter", bot: "Bot") -> List[VoiceRegion]: +async def _list_voice_regions(adapter: "Adapter", bot: "Bot") -> list[VoiceRegion]: """https://discord.com/developers/docs/resources/voice#list-voice-regions""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2828,7 +2826,7 @@ async def _list_voice_regions(adapter: "Adapter", bot: "Bot") -> List[VoiceRegio url=adapter.base_url / "voice/regions", ) return type_validate_python( - List[VoiceRegion], await _request(adapter, bot, request) + list[VoiceRegion], await _request(adapter, bot, request) ) @@ -2850,7 +2848,7 @@ async def _create_webhook( async def _get_channel_webhooks( adapter: "Adapter", bot: "Bot", channel_id: SnowflakeType -) -> List[Webhook]: +) -> list[Webhook]: """https://discord.com/developers/docs/resources/webhook#get-channel-webhooks""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2858,12 +2856,12 @@ async def _get_channel_webhooks( method="GET", url=adapter.base_url / f"channels/{channel_id}/webhooks", ) - return type_validate_python(List[Webhook], await _request(adapter, bot, request)) + return type_validate_python(list[Webhook], await _request(adapter, bot, request)) async def _get_guild_webhooks( adapter: "Adapter", bot: "Bot", guild_id: SnowflakeType -) -> List[Webhook]: +) -> list[Webhook]: """https://discord.com/developers/docs/resources/webhook#get-guild-webhooks""" headers = {"Authorization": adapter.get_authorization(bot.bot_info)} request = Request( @@ -2871,7 +2869,7 @@ async def _get_guild_webhooks( method="GET", url=adapter.base_url / f"guilds/{guild_id}/webhooks", ) - return type_validate_python(List[Webhook], await _request(adapter, bot, request)) + return type_validate_python(list[Webhook], await _request(adapter, bot, request)) async def _get_webhook( @@ -3111,7 +3109,7 @@ async def _get_current_authorization_information( ) -API_HANDLERS: Dict[str, Callable[..., Awaitable[Any]]] = { +API_HANDLERS: dict[str, Callable[..., Awaitable[Any]]] = { "get_global_application_commands": _get_global_application_commands, "create_global_application_command": _create_global_application_command, "get_global_application_command": _get_global_application_command, diff --git a/nonebot/adapters/discord/api/model.py b/nonebot/adapters/discord/api/model.py index 6026e60..e418886 100644 --- a/nonebot/adapters/discord/api/model.py +++ b/nonebot/adapters/discord/api/model.py @@ -4,12 +4,9 @@ from typing import ( TYPE_CHECKING, Any, - Dict, Generic, - List, Literal, Optional, - Tuple, TypeVar, Union, final, @@ -156,16 +153,16 @@ class ApplicationCommand(BaseModel): """Guild ID of the command, if not global""" name: str """Name of command, 1-32 characters""" - name_localizations: MissingOrNullable[Dict[str, str]] = UNSET + name_localizations: MissingOrNullable[dict[str, str]] = UNSET """Localization dictionary for name field. Values follow the same restrictions as name""" description: Missing[str] = UNSET """Description for CHAT_INPUT commands, 1-100 characters. Empty string for USER and MESSAGE commands""" - description_localizations: MissingOrNullable[Dict[str, str]] = UNSET + description_localizations: MissingOrNullable[dict[str, str]] = UNSET """Localization dictionary for description field. Values follow the same restrictions as description""" - options: MissingOrNullable[List["ApplicationCommandOption"]] = UNSET + options: MissingOrNullable[list["ApplicationCommandOption"]] = UNSET """Parameters for the command, max of 25""" default_member_permissions: Optional[str] = Field(...) """Set of permissions represented as a bit set""" @@ -185,10 +182,10 @@ class ApplicationCommand(BaseModel): class ApplicationCommandCreate(BaseModel): type: ApplicationCommandType = ApplicationCommandType.CHAT_INPUT name: str - name_localizations: Optional[Dict[str, str]] = None + name_localizations: Optional[dict[str, str]] = None description: Optional[str] = None - description_localizations: Optional[Dict[str, str]] = None - options: Optional[List["AnyCommandOption"]] = None + description_localizations: Optional[dict[str, str]] = None + options: Optional[list["AnyCommandOption"]] = None default_member_permissions: Optional[str] = None dm_permission: Optional[bool] = None default_permission: Optional[bool] = None @@ -198,9 +195,9 @@ class ApplicationCommandCreate(BaseModel): class CommandOptionBase(BaseModel): type: ApplicationCommandOptionType name: str - name_localizations: Optional[Dict[str, str]] = None + name_localizations: Optional[dict[str, str]] = None description: str - description_localizations: Optional[Dict[str, str]] = None + description_localizations: Optional[dict[str, str]] = None class ApplicationCommandOption(CommandOptionBase): @@ -215,23 +212,23 @@ class ApplicationCommandOption(CommandOptionBase): """Type of option""" name: str """1-32 character name""" - name_localizations: MissingOrNullable[Dict[str, str]] = UNSET + name_localizations: MissingOrNullable[dict[str, str]] = UNSET """Localization dictionary for the name field. Values follow the same restrictions as name""" description: Missing[str] = UNSET """1-100 character description""" - description_localizations: MissingOrNullable[Dict[str, str]] = UNSET + description_localizations: MissingOrNullable[dict[str, str]] = UNSET """Localization dictionary for the description field. Values follow the same restrictions as description""" required: Missing[bool] = UNSET """If the parameter is required or optional--default false""" - choices: Missing[List["ApplicationCommandOptionChoice"]] = UNSET + choices: Missing[list["ApplicationCommandOptionChoice"]] = UNSET """Choices for STRING, INTEGER, and NUMBER types for the user to pick from, max 25""" - options: MissingOrNullable[List["ApplicationCommandOption"]] = UNSET + options: MissingOrNullable[list["ApplicationCommandOption"]] = UNSET """If the option is a subcommand or subcommand group type, these nested options will be the parameters""" - channel_types: Missing[List[ChannelType]] = UNSET + channel_types: Missing[list[ChannelType]] = UNSET """ If the option is a channel type, the channels shown will be restricted to these types""" min_value: Missing[Union[int, float]] = UNSET @@ -251,7 +248,7 @@ class ApplicationCommandOption(CommandOptionBase): class OptionChoice(GenericModel, Generic[T]): name: str - name_localizations: Optional[Dict[str, str]] = None + name_localizations: Optional[dict[str, str]] = None value: T @@ -260,7 +257,7 @@ class SubCommandOption(CommandOptionBase): ApplicationCommandOptionType.SUB_COMMAND, init=False ) options: Optional[ - List[ + list[ Union[ "IntegerOption", "StringOption", @@ -280,14 +277,14 @@ class SubCommandGroupOption(CommandOptionBase): type: Literal[ApplicationCommandOptionType.SUB_COMMAND_GROUP] = Field( ApplicationCommandOptionType.SUB_COMMAND_GROUP, init=False ) - options: Optional[List[SubCommandOption]] = None + options: Optional[list[SubCommandOption]] = None class IntegerOption(CommandOptionBase): type: Literal[ApplicationCommandOptionType.INTEGER] = Field( ApplicationCommandOptionType.INTEGER, init=False ) - choices: Optional[List[OptionChoice[int]]] = None + choices: Optional[list[OptionChoice[int]]] = None min_value: Optional[int] = None max_value: Optional[int] = None autocomplete: Optional[bool] = None @@ -298,7 +295,7 @@ class StringOption(CommandOptionBase): type: Literal[ApplicationCommandOptionType.STRING] = Field( ApplicationCommandOptionType.STRING, init=False ) - choices: Optional[List[OptionChoice[str]]] = None + choices: Optional[list[OptionChoice[str]]] = None min_length: Optional[int] = None max_length: Optional[int] = None autocomplete: Optional[bool] = None @@ -323,7 +320,7 @@ class ChannelOption(CommandOptionBase): type: Literal[ApplicationCommandOptionType.CHANNEL] = Field( ApplicationCommandOptionType.CHANNEL, init=False ) - channel_types: Optional[List[ChannelType]] = None + channel_types: Optional[list[ChannelType]] = None required: bool = False @@ -345,7 +342,7 @@ class NumberOption(CommandOptionBase): type: Literal[ApplicationCommandOptionType.NUMBER] = Field( ApplicationCommandOptionType.NUMBER, init=False ) - choices: Optional[List[OptionChoice[float]]] = None + choices: Optional[list[OptionChoice[float]]] = None min_value: Optional[float] = None required: bool = False @@ -383,7 +380,7 @@ class ApplicationCommandOptionChoice(BaseModel): name: str """1-100 character choice name""" - name_localizations: MissingOrNullable[Dict[str, str]] = UNSET + name_localizations: MissingOrNullable[dict[str, str]] = UNSET """Localization dictionary for the name field. Values follow the same restrictions as name""" value: Union[str, int, float] @@ -406,7 +403,7 @@ class GuildApplicationCommandPermissions(BaseModel): """ID of the application the command belongs to""" guild_id: Snowflake """ID of the guild""" - permissions: List["ApplicationCommandPermissions"] + permissions: list["ApplicationCommandPermissions"] """Permissions for the command in the guild, max of 100""" @@ -443,7 +440,7 @@ class ActionRow(BaseModel): """ type: ComponentType = Field(default=ComponentType.ActionRow) - components: List[Union["Button", "SelectMenu", "TextInput"]] + components: list[Union["Button", "SelectMenu", "TextInput"]] class ComponentEmoji(BaseModel): @@ -514,10 +511,10 @@ class SelectMenu(BaseModel): """Type of select menu component""" custom_id: str """ID for the select menu; max 100 characters""" - options: Missing[List["SelectOption"]] = UNSET + options: Missing[list["SelectOption"]] = UNSET """Specified choices in a select menu (only required and available for string selects; max 25""" - channel_types: Missing[List[ChannelType]] = UNSET + channel_types: Missing[list[ChannelType]] = UNSET """List of channel types to include in the channel select component""" placeholder: Missing[str] = UNSET """Placeholder text if nothing is selected; max 150 characters""" @@ -559,10 +556,10 @@ class SelectMenuResolved(BaseModel): see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-resolved-object """ - users: Missing[Dict[Snowflake, "User"]] = UNSET - roles: Missing[Dict[Snowflake, "Role"]] = UNSET - channels: Missing[Dict[Snowflake, "Channel"]] = UNSET - members: Missing[Dict[Snowflake, "GuildMember"]] = UNSET + users: Missing[dict[Snowflake, "User"]] = UNSET + roles: Missing[dict[Snowflake, "Role"]] = UNSET + channels: Missing[dict[Snowflake, "Channel"]] = UNSET + members: Missing[dict[Snowflake, "GuildMember"]] = UNSET class TextInput(BaseModel): @@ -659,7 +656,7 @@ class ApplicationCommandData(BaseModel): """the type of the invoked command""" resolved: Missing["ResolvedData"] = UNSET """converted users + roles + channels + attachments""" - options: Missing[List["ApplicationCommandInteractionDataOption"]] = UNSET + options: Missing[list["ApplicationCommandInteractionDataOption"]] = UNSET """the params + values from the user""" guild_id: Missing[Snowflake] = UNSET """the id of the guild the command is registered to""" @@ -679,7 +676,7 @@ class MessageComponentData(BaseModel): """the custom_id of the component""" component_type: ComponentType """the type of the component""" - values: Missing[List[str]] = UNSET + values: Missing[list[str]] = UNSET """values the user selected in a select menu component""" @@ -691,7 +688,7 @@ class ModalSubmitData(BaseModel): custom_id: str """the custom_id of the modal""" - components: List[Component] + components: list[Component] """the values submitted by the user""" @@ -712,17 +709,17 @@ class ResolvedData(BaseModel): see https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure """ - users: Missing[Dict[Snowflake, "User"]] = UNSET + users: Missing[dict[Snowflake, "User"]] = UNSET """the ids and User objects""" - members: Missing[Dict[Snowflake, "GuildMember"]] = UNSET + members: Missing[dict[Snowflake, "GuildMember"]] = UNSET """the ids and partial Member objects""" - roles: Missing[Dict[Snowflake, "Role"]] = UNSET + roles: Missing[dict[Snowflake, "Role"]] = UNSET """the ids and Role objects""" - channels: Missing[Dict[Snowflake, "Channel"]] = UNSET + channels: Missing[dict[Snowflake, "Channel"]] = UNSET """the ids and partial Channel objects""" - messages: Missing[Dict[Snowflake, "MessageGet"]] = UNSET + messages: Missing[dict[Snowflake, "MessageGet"]] = UNSET """the ids and partial Message objects""" - attachments: Missing[Dict[Snowflake, "Attachment"]] = UNSET + attachments: Missing[dict[Snowflake, "Attachment"]] = UNSET """the ids and attachment objects""" @@ -742,7 +739,7 @@ class ApplicationCommandInteractionDataOption(BaseModel): """Value of application command option type""" value: Missing[Union[str, int, float, bool]] = UNSET """Value of the option resulting from user input""" - options: Missing[List["ApplicationCommandInteractionDataOption"]] = UNSET + options: Missing[list["ApplicationCommandInteractionDataOption"]] = UNSET """Present if this option is a group or subcommand""" focused: Missing[bool] = UNSET """true if this option is the currently focused option for autocomplete""" @@ -790,20 +787,20 @@ class InteractionCallbackMessage(BaseModel): """is the response TTS""" content: Optional[str] = None """message content""" - embeds: Optional[List["Embed"]] = None + embeds: Optional[list["Embed"]] = None """supports up to 10 embeds""" allowed_mentions: Optional["AllowedMention"] = None """allowed mentions object""" flags: Optional[MessageFlag] = None """message flags combined as a bitfield (only SUPPRESS_EMBEDS and EPHEMERAL can be set)""" - components: Optional[List[Component]] = None + components: Optional[list[Component]] = None """message components""" - attachments: Optional[List["AttachmentSend"]] = None + attachments: Optional[list["AttachmentSend"]] = None """attachment objects with filename and description. See Uploading Files for details.""" - files: Optional[List["File"]] = None + files: Optional[list["File"]] = None class InteractionCallbackAutocomplete(BaseModel): @@ -812,7 +809,7 @@ class InteractionCallbackAutocomplete(BaseModel): see https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-autocomplete """ - choices: List[ApplicationCommandOptionChoice] + choices: list[ApplicationCommandOptionChoice] """autocomplete choices (max of 25 choices)""" @@ -828,7 +825,7 @@ class InteractionCallbackModal(BaseModel): """a developer-defined identifier for the modal, max 100 characters""" title: str """the title of the popup modal, max 45 characters""" - components: List[Component] + components: list[Component] """between 1 and 5 (inclusive) components that make up the modal""" @@ -853,11 +850,11 @@ class Application(BaseModel): """the id of the app""" name: str """the name of the app""" - icon: Optional[str] + icon: Optional[str] = None """the icon hash of the app""" description: str """the description of the app""" - rpc_origins: Missing[List[str]] = UNSET + rpc_origins: Missing[list[str]] = UNSET """an array of rpc origin urls, if rpc is enabled""" bot_public: bool """when false only app owner can join the app's bot to guilds""" @@ -873,7 +870,7 @@ class Application(BaseModel): verify_key: str """the hex encoded key for verification in interactions and the GameSDK's GetTicket""" - team: Optional["Team"] + team: Optional["Team"] = None """if the application belongs to a team, this will be a list of the members of that team""" guild_id: Missing[Snowflake] = UNSET @@ -889,7 +886,7 @@ class Application(BaseModel): """the application's default rich presence invite cover image hash""" flags: Missing[ApplicationFlag] = UNSET """the application's public flags""" - tags: Missing[List[str]] = UNSET + tags: Missing[list[str]] = UNSET """up to 5 tags describing the content and functionality of the application""" install_params: Missing["InstallParams"] = UNSET """settings for the application's default in-app authorization link, if enabled""" @@ -907,7 +904,7 @@ class InstallParams(BaseModel): see https://discord.com/developers/docs/resources/application#install-params-object """ - scopes: List[str] + scopes: list[str] """the scopes to add the application to the server with""" permissions: str """ the permissions to request for the bot role""" @@ -930,11 +927,11 @@ class ApplicationRoleConnectionMetadata(BaseModel): (must be a-z, 0-9, or _ characters; 1-50 characters)""" name: str """name of the metadata field (1-100 characters)""" - name_localizations: Missing[Dict[str, str]] = UNSET + name_localizations: Missing[dict[str, str]] = UNSET """translations of the name""" description: str """description of the metadata field (1-200 characters)""" - description_localizations: Missing[Dict[str, str]] = UNSET + description_localizations: Missing[dict[str, str]] = UNSET """translations of the description""" @@ -947,21 +944,21 @@ class AuditLog(BaseModel): see https://discord.com/developers/docs/resources/audit-log#audit-log-object""" - application_commands: List[ApplicationCommand] + application_commands: list[ApplicationCommand] """List of application commands referenced in the audit log""" - audit_log_entries: List["AuditLogEntry"] + audit_log_entries: list["AuditLogEntry"] """List of audit log entries, sorted from most to least recent""" - auto_moderation_rules: List["AutoModerationRule"] + auto_moderation_rules: list["AutoModerationRule"] """List of auto moderation rules referenced in the audit log""" - guild_scheduled_events: List["GuildScheduledEvent"] + guild_scheduled_events: list["GuildScheduledEvent"] """List of guild scheduled events referenced in the audit log""" - integrations: List["Integration"] # partial integration object + integrations: list["Integration"] # partial integration object """List of partial integration objects""" - threads: List["Channel"] # thread-specific channel objects + threads: list["Channel"] # thread-specific channel objects """List of threads referenced in the audit log""" - users: List["User"] + users: list["User"] """List of users referenced in the audit log""" - webhooks: List["Webhook"] + webhooks: list["Webhook"] """List of webhooks referenced in the audit log""" @@ -971,11 +968,11 @@ class AuditLogEntry(BaseModel): see https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object """ - target_id: Optional[str] + target_id: Optional[str] = None """ID of the affected entity (webhook, user, role, etc.)""" - changes: Missing[List["AuditLogChange"]] = UNSET + changes: Missing[list["AuditLogChange"]] = UNSET """Changes made to the target_id""" - user_id: Optional[Snowflake] + user_id: Optional[Snowflake] = None """User or app that made the changes""" id: Snowflake """ID of the entry""" @@ -1065,13 +1062,13 @@ class AutoModerationRule(BaseModel): """the rule trigger type""" trigger_metadata: "TriggerMetadata" """the rule trigger metadata""" - actions: List["AutoModerationAction"] + actions: list["AutoModerationAction"] """the actions which will execute when the rule is triggered""" enabled: bool """whether the rule is enabled""" - exempt_roles: List[Snowflake] + exempt_roles: list[Snowflake] """the role ids that should not be affected by the rule (Maximum of 20)""" - exempt_channels: List[Snowflake] + exempt_channels: list[Snowflake] """the channel ids that should not be affected by the rule (Maximum of 50)""" @@ -1082,14 +1079,14 @@ class TriggerMetadata(BaseModel): see https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata """ - keyword_filter: List[str] + keyword_filter: list[str] """substrings which will be searched for in content (Maximum of 1000)""" - regex_patterns: List[str] + regex_patterns: list[str] """regular expression patterns which will be matched against content (Maximum of 10)""" - presets: List[KeywordPresetType] + presets: list[KeywordPresetType] """the internally pre-defined wordsets which will be searched for in content""" - allow_list: List[str] + allow_list: list[str] """substrings which should not trigger the rule (Maximum of 100 or 1000)""" mention_total_limit: int """total number of unique role and user mentions allowed @@ -1129,14 +1126,14 @@ class CreateAndModifyAutoModerationRuleParams(BaseModel): see https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule """ - name: Optional[str] - event_type: Optional[AutoModerationRuleEventType] - trigger_type: Optional[TriggerType] - trigger_metadata: Optional[TriggerMetadata] - actions: Optional[List[AutoModerationAction]] - enabled: Optional[bool] - exempt_roles: Optional[List[Snowflake]] - exempt_channels: Optional[List[Snowflake]] + name: Optional[str] = None + event_type: Optional[AutoModerationRuleEventType] = None + trigger_type: Optional[TriggerType] = None + trigger_metadata: Optional[TriggerMetadata] = None + actions: Optional[list[AutoModerationAction]] = None + enabled: Optional[bool] = None + exempt_roles: Optional[list[Snowflake]] = None + exempt_channels: Optional[list[Snowflake]] = None # Channel @@ -1157,7 +1154,7 @@ class Channel(BaseModel): received over gateway guild dispatches)""" position: Missing[int] = UNSET """sorting position of the channel""" - permission_overwrites: Missing[List["Overwrite"]] = UNSET + permission_overwrites: Missing[list["Overwrite"]] = UNSET """explicit permission overwrites for members and roles""" name: MissingOrNullable[str] = UNSET """the name of the channel (1-100 characters)""" @@ -1178,7 +1175,7 @@ class Channel(BaseModel): """amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected""" - recipients: Missing[List["User"]] = UNSET + recipients: Missing[list["User"]] = UNSET """the recipients of the DM""" icon: MissingOrNullable[str] = UNSET """icon hash of the group DM""" @@ -1223,9 +1220,9 @@ class Channel(BaseModel): total_message_sent: Missing[int] = UNSET """number of messages ever sent in a thread, it's similar to message_count on message creation, but will not decrement the number when a message is deleted""" - available_tags: Missing[List["ForumTag"]] = UNSET + available_tags: Missing[list["ForumTag"]] = UNSET """the set of tags that can be used in a GUILD_FORUM channel""" - applied_tags: Missing[List[Snowflake]] = UNSET + applied_tags: Missing[list[Snowflake]] = UNSET """the IDs of the set of tags that have been applied to a thread in a GUILD_FORUM channel""" default_reaction_emoji: MissingOrNullable["DefaultReaction"] = UNSET @@ -1256,12 +1253,12 @@ class MessageGet(BaseModel): edited_timestamp: Optional[datetime.datetime] = Field(...) tts: bool mention_everyone: bool - mentions: List["User"] - mention_roles: List[str] - mention_channels: Missing[List["ChannelMention"]] = UNSET - attachments: List["Attachment"] - embeds: List["Embed"] - reactions: Missing[List["Reaction"]] = UNSET + mentions: list["User"] + mention_roles: list[str] + mention_channels: Missing[list["ChannelMention"]] = UNSET + attachments: list["Attachment"] + embeds: list["Embed"] + reactions: Missing[list["Reaction"]] = UNSET nonce: Missing[Union[int, str]] = UNSET pinned: bool webhook_id: Missing[Snowflake] = UNSET @@ -1274,9 +1271,9 @@ class MessageGet(BaseModel): referenced_message: MissingOrNullable["MessageGet"] = UNSET interaction: Missing[MessageInteraction] = UNSET thread: Missing[Channel] = UNSET - components: Missing[List[DirectComponent]] = UNSET - sticker_items: Missing[List["StickerItem"]] = UNSET - stickers: Missing[List["Sticker"]] = UNSET + components: Missing[list[DirectComponent]] = UNSET + sticker_items: Missing[list["StickerItem"]] = UNSET + stickers: Missing[list["Sticker"]] = UNSET position: Missing[int] = UNSET role_subscription_data: Missing["RoleSubscriptionData"] = UNSET @@ -1288,7 +1285,7 @@ class MessageActivity(BaseModel): """ type: MessageActivityType - party_id: Optional[str] + party_id: Optional[str] = None class MessageReference(BaseModel): @@ -1351,8 +1348,8 @@ class ThreadMetadata(BaseModel): auto_archive_duration: int archive_timestamp: str locked: bool - invitable: Optional[bool] - create_timestamp: Optional[str] + invitable: Optional[bool] = None + create_timestamp: Optional[str] = None class ThreadMember(BaseModel): @@ -1360,11 +1357,11 @@ class ThreadMember(BaseModel): see https://discord.com/developers/docs/resources/channel#thread-member-object""" - id: Optional[str] - user_id: Optional[str] + id: Optional[str] = None + user_id: Optional[str] = None join_timestamp: str flags: int - member: Optional["GuildMember"] + member: Optional["GuildMember"] = None class DefaultReaction(BaseModel): @@ -1372,8 +1369,8 @@ class DefaultReaction(BaseModel): see https://discord.com/developers/docs/resources/channel#default-reaction-object""" - emoji_id: Optional[str] - emoji_name: Optional[str] + emoji_id: Optional[str] = None + emoji_name: Optional[str] = None class ForumTag(BaseModel): @@ -1386,7 +1383,7 @@ class ForumTag(BaseModel): name: str moderated: bool emoji_id: MissingOrNullable[Snowflake] = UNSET - emoji_name: Optional[str] + emoji_name: Optional[str] = None class Embed(BaseModel): @@ -1406,7 +1403,7 @@ class Embed(BaseModel): video: Missing["EmbedVideo"] = UNSET provider: Missing["EmbedProvider"] = UNSET author: Missing["EmbedAuthor"] = UNSET - fields: Missing[List["EmbedField"]] = UNSET + fields: Missing[list["EmbedField"]] = UNSET class EmbedThumbnail(BaseModel): @@ -1529,11 +1526,11 @@ class AllowedMention(BaseModel): see https://discord.com/developers/docs/resources/channel#allowed-mentions-object""" - parse: List[AllowedMentionType] + parse: list[AllowedMentionType] """An array of allowed mention types to parse from the content.""" - roles: List[Snowflake] + roles: list[Snowflake] """Array of role_ids to mention (Max size of 100)""" - users: List[Snowflake] + users: list[Snowflake] """ Array of user_ids to mention (Max size of 100)""" replied_user: bool """For replies, whether to mention the author of the message @@ -1558,8 +1555,8 @@ class ArchivedThreadsResponse(BaseModel): see https://discord.com/developers/docs/resources/channel#list-public-archived-threads-response-body """ - threads: List[Channel] - members: List[ThreadMember] + threads: list[Channel] + members: list[ThreadMember] has_more: bool @@ -1574,7 +1571,7 @@ class AttachmentSend(BaseModel): see https://discord.com/developers/docs/resources/channel#attachment-object""" filename: str - description: Optional[str] + description: Optional[str] = None class MessageSend(BaseModel): @@ -1582,17 +1579,17 @@ class MessageSend(BaseModel): see https://discord.com/developers/docs/resources/channel#create-message""" - content: Optional[str] - nonce: Optional[Union[int, str]] - tts: Optional[bool] - embeds: Optional[List[Embed]] - allowed_mentions: Optional[AllowedMention] - message_reference: Optional[MessageReference] - components: Optional[List[DirectComponent]] - sticker_ids: Optional[List[Snowflake]] - files: Optional[List[File]] - attachments: Optional[List[AttachmentSend]] - flags: Optional[MessageFlag] + content: Optional[str] = None + nonce: Optional[Union[int, str]] = None + tts: Optional[bool] = None + embeds: Optional[list[Embed]] = None + allowed_mentions: Optional[AllowedMention] = None + message_reference: Optional[MessageReference] = None + components: Optional[list[DirectComponent]] = None + sticker_ids: Optional[list[Snowflake]] = None + files: Optional[list[File]] = None + attachments: Optional[list[AttachmentSend]] = None + flags: Optional[MessageFlag] = None class ModifyChannelParams(BaseModel): @@ -1601,25 +1598,25 @@ class ModifyChannelParams(BaseModel): see https://discord.com/developers/docs/resources/channel#modify-channel-json-params-guild-channel """ - name: Optional[str] - type: Optional[ChannelType] - position: Optional[int] - topic: Optional[str] - nsfw: Optional[bool] - rate_limit_per_user: Optional[int] - bitrate: Optional[int] - user_limit: Optional[int] - permission_overwrites: Optional[List[Overwrite]] - parent_id: Optional[Snowflake] - rtc_region: Optional[str] - video_quality_mode: Optional[VideoQualityMode] - default_auto_archive_duration: Optional[int] - flags: Optional[ChannelFlags] - available_tags: Optional[List[ForumTag]] - default_reaction_emoji: Optional[DefaultReaction] - default_thread_rate_limit_per_user: Optional[int] - default_sort_order: Optional[SortOrderTypes] - default_forum_layout: Optional[ForumLayoutTypes] + name: Optional[str] = None + type: Optional[ChannelType] = None + position: Optional[int] = None + topic: Optional[str] = None + nsfw: Optional[bool] = None + rate_limit_per_user: Optional[int] = None + bitrate: Optional[int] = None + user_limit: Optional[int] = None + permission_overwrites: Optional[list[Overwrite]] = None + parent_id: Optional[Snowflake] = None + rtc_region: Optional[str] = None + video_quality_mode: Optional[VideoQualityMode] = None + default_auto_archive_duration: Optional[int] = None + flags: Optional[ChannelFlags] = None + available_tags: Optional[list[ForumTag]] = None + default_reaction_emoji: Optional[DefaultReaction] = None + default_thread_rate_limit_per_user: Optional[int] = None + default_sort_order: Optional[SortOrderTypes] = None + default_forum_layout: Optional[ForumLayoutTypes] = None # Emoji @@ -1631,11 +1628,11 @@ class Emoji(BaseModel): see https://discord.com/developers/docs/resources/emoji#emoji-object""" - id: Optional[str] + id: Optional[str] = None """emoji id""" - name: Optional[str] + name: Optional[str] = None """emoji name(can be null only in reaction emoji objects)""" - roles: Missing[List[Snowflake]] = UNSET + roles: Missing[list[Snowflake]] = UNSET """roles allowed to use this emoji""" user: Missing["User"] = UNSET """user that created this emoji""" @@ -1661,7 +1658,7 @@ class Guild(BaseModel): icon: Optional[str] = Field(...) icon_hash: MissingOrNullable[str] = UNSET splash: Optional[str] = Field(...) - discovery_splash: Optional[str] + discovery_splash: Optional[str] = None owner: Missing[bool] = UNSET owner_id: Snowflake permissions: Missing[str] = UNSET @@ -1673,9 +1670,9 @@ class Guild(BaseModel): verification_level: VerificationLevel default_message_notifications: DefaultMessageNotificationLevel explicit_content_filter: ExplicitContentFilterLevel - roles: List["Role"] - emojis: List[Emoji] - features: List[GuildFeature] + roles: list["Role"] + emojis: list[Emoji] + features: list[GuildFeature] mfa_level: MFALevel application_id: Optional[Snowflake] = Field(...) system_channel_id: Optional[Snowflake] = Field(...) @@ -1696,7 +1693,7 @@ class Guild(BaseModel): approximate_presence_count: Missing[int] = UNSET welcome_screen: Missing["WelcomeScreen"] = UNSET nsfw_level: GuildNSFWLevel - stickers: Missing[List["Sticker"]] = UNSET + stickers: Missing[list["Sticker"]] = UNSET premium_progress_bar_enabled: bool @@ -1710,7 +1707,7 @@ class CurrentUserGuild(BaseModel): icon: Optional[str] = Field(...) owner: Missing[bool] = UNSET permissions: Missing[str] = UNSET - features: List[GuildFeature] + features: list[GuildFeature] class UnavailableGuild(BaseModel): @@ -1729,15 +1726,15 @@ class GuildPreview(BaseModel): id: Snowflake name: str - icon: Optional[str] - splash: Optional[str] - discovery_splash: Optional[str] - emojis: List[Emoji] - features: List[GuildFeature] + icon: Optional[str] = None + splash: Optional[str] = None + discovery_splash: Optional[str] = None + emojis: list[Emoji] + features: list[GuildFeature] approximate_member_count: int approximate_presence_count: int - description: Optional[str] - stickers: List["Sticker"] + description: Optional[str] = None + stickers: list["Sticker"] class GuildWidgetSettings(BaseModel): @@ -1747,7 +1744,7 @@ class GuildWidgetSettings(BaseModel): """ enabled: bool - channel_id: Optional[Snowflake] + channel_id: Optional[Snowflake] = None class GuildWidget(BaseModel): @@ -1757,9 +1754,9 @@ class GuildWidget(BaseModel): id: Snowflake name: str - instant_invite: Optional[str] - channels: List["Channel"] # partial channel objects - members: List["User"] # partial user objects + instant_invite: Optional[str] = None + channels: list["Channel"] # partial channel objects + members: list["User"] # partial user objects presence_count: int @@ -1771,7 +1768,7 @@ class GuildMember(BaseModel): user: Missing["User"] = UNSET nick: MissingOrNullable[str] = UNSET avatar: MissingOrNullable[str] = UNSET - roles: List[Snowflake] + roles: list[Snowflake] joined_at: datetime.datetime premium_since: MissingOrNullable[datetime.datetime] = UNSET deaf: Missing[bool] = UNSET @@ -1797,12 +1794,12 @@ class Integration(BaseModel): expire_behavior: Missing[IntegrationExpireBehaviors] = UNSET expire_grace_period: Missing[int] = UNSET user: Missing["User"] = UNSET - account: Optional["IntegrationAccount"] + account: Optional["IntegrationAccount"] = None synced_at: Missing[datetime.datetime] = UNSET subscriber_count: Missing[int] = UNSET revoked: Missing[bool] = UNSET application: Missing["IntegrationApplication"] = UNSET - scopes: Missing[List[str]] = UNSET # TODO: OAuth2 scopes + scopes: Missing[list[str]] = UNSET # TODO: OAuth2 scopes class IntegrationAccount(BaseModel): @@ -1823,7 +1820,7 @@ class IntegrationApplication(BaseModel): id: Snowflake name: str - icon: Optional[str] + icon: Optional[str] = None description: str bot: Missing["User"] = UNSET @@ -1833,7 +1830,7 @@ class Ban(BaseModel): see https://discord.com/developers/docs/resources/guild#ban-object""" - reason: Optional[str] + reason: Optional[str] = None user: "User" @@ -1842,8 +1839,8 @@ class WelcomeScreen(BaseModel): see https://discord.com/developers/docs/resources/guild#welcome-screen-object""" - description: Optional[str] - welcome_channels: List["WelcomeScreenChannel"] + description: Optional[str] = None + welcome_channels: list["WelcomeScreenChannel"] class WelcomeScreenChannel(BaseModel): @@ -1854,8 +1851,8 @@ class WelcomeScreenChannel(BaseModel): channel_id: Snowflake description: str - emoji_id: Optional[Snowflake] - emoji_name: Optional[str] + emoji_id: Optional[Snowflake] = None + emoji_name: Optional[str] = None class GuildOnboarding(BaseModel): @@ -1864,8 +1861,8 @@ class GuildOnboarding(BaseModel): see https://discord.com/developers/docs/resources/guild#guild-onboarding-object""" guild_id: Snowflake - prompts: List["OnboardingPrompt"] - default_channel_ids: List[Snowflake] + prompts: list["OnboardingPrompt"] + default_channel_ids: list[Snowflake] enabled: bool @@ -1877,7 +1874,7 @@ class OnboardingPrompt(BaseModel): id: Snowflake type: OnboardingPromptType - options: List["OnboardingPromptOption"] + options: list["OnboardingPromptOption"] title: str single_select: bool required: bool @@ -1891,11 +1888,11 @@ class OnboardingPromptOption(BaseModel): """ id: Snowflake - channel_ids: List[Snowflake] - role_ids: List[Snowflake] + channel_ids: list[Snowflake] + role_ids: list[Snowflake] emoji: Emoji title: str - description: Optional[str] + description: Optional[str] = None class MembershipScreening(BaseModel): @@ -1911,17 +1908,17 @@ class CreateGuildParams(BaseModel): see https://discord.com/developers/docs/resources/guild#create-guild""" name: str - region: Optional[str] - icon: Optional[str] - verification_level: Optional[VerificationLevel] - default_message_notifications: Optional[DefaultMessageNotificationLevel] - explicit_content_filter: Optional[ExplicitContentFilterLevel] - roles: Optional[List["Role"]] - channels: Optional[List[Channel]] - afk_channel_id: Optional[Snowflake] - afk_timeout: Optional[int] - system_channel_id: Optional[Snowflake] - system_channel_flags: Optional[SystemChannelFlags] + region: Optional[str] = None + icon: Optional[str] = None + verification_level: Optional[VerificationLevel] = None + default_message_notifications: Optional[DefaultMessageNotificationLevel] = None + explicit_content_filter: Optional[ExplicitContentFilterLevel] = None + roles: Optional[list["Role"]] = None + channels: Optional[list[Channel]] = None + afk_channel_id: Optional[Snowflake] = None + afk_timeout: Optional[int] = None + system_channel_id: Optional[Snowflake] = None + system_channel_flags: Optional[SystemChannelFlags] = None class ModifyGuildParams(BaseModel): @@ -1930,25 +1927,25 @@ class ModifyGuildParams(BaseModel): see https://discord.com/developers/docs/resources/guild#modify-guild""" name: str - region: Optional[str] - verification_level: Optional[VerificationLevel] - default_message_notifications: Optional[DefaultMessageNotificationLevel] - explicit_content_filter: Optional[ExplicitContentFilterLevel] - afk_channel_id: Optional[Snowflake] - afk_timeout: Optional[int] - icon: Optional[str] - owner_id: Optional[Snowflake] - splash: Optional[str] - discovery_splash: Optional[str] - banner: Optional[str] - system_channel_id: Optional[Snowflake] - system_channel_flags: Optional[SystemChannelFlags] - rules_channel_id: Optional[Snowflake] - public_updates_channel_id: Optional[Snowflake] - preferred_locale: Optional[str] - features: Optional[List[GuildFeature]] - description: Optional[str] - premium_progress_bar_enabled: Optional[bool] + region: Optional[str] = None + verification_level: Optional[VerificationLevel] = None + default_message_notifications: Optional[DefaultMessageNotificationLevel] = None + explicit_content_filter: Optional[ExplicitContentFilterLevel] = None + afk_channel_id: Optional[Snowflake] = None + afk_timeout: Optional[int] = None + icon: Optional[str] = None + owner_id: Optional[Snowflake] = None + splash: Optional[str] = None + discovery_splash: Optional[str] = None + banner: Optional[str] = None + system_channel_id: Optional[Snowflake] = None + system_channel_flags: Optional[SystemChannelFlags] = None + rules_channel_id: Optional[Snowflake] = None + public_updates_channel_id: Optional[Snowflake] = None + preferred_locale: Optional[str] = None + features: Optional[list[GuildFeature]] = None + description: Optional[str] = None + premium_progress_bar_enabled: Optional[bool] = None class CreateGuildChannelParams(BaseModel): @@ -1957,21 +1954,21 @@ class CreateGuildChannelParams(BaseModel): see https://discord.com/developers/docs/resources/guild#create-guild-channel""" name: str - type: Optional[ChannelType] - topic: Optional[str] - bitrate: Optional[int] - user_limit: Optional[int] - rate_limit_per_user: Optional[int] - position: Optional[int] - permission_overwrites: Optional[List["Overwrite"]] - parent_id: Optional[Snowflake] - nsfw: Optional[bool] - rtc_region: Optional[str] - video_quality_mode: Optional[VideoQualityMode] - default_auto_archive_duration: Optional[int] - default_reaction_emoji: Optional[DefaultReaction] - available_tags: Optional[List[ForumTag]] - default_sort_order: Optional[SortOrderTypes] + type: Optional[ChannelType] = None + topic: Optional[str] = None + bitrate: Optional[int] = None + user_limit: Optional[int] = None + rate_limit_per_user: Optional[int] = None + position: Optional[int] = None + permission_overwrites: Optional[list["Overwrite"]] = None + parent_id: Optional[Snowflake] = None + nsfw: Optional[bool] = None + rtc_region: Optional[str] = None + video_quality_mode: Optional[VideoQualityMode] = None + default_auto_archive_duration: Optional[int] = None + default_reaction_emoji: Optional[DefaultReaction] = None + available_tags: Optional[list[ForumTag]] = None + default_sort_order: Optional[SortOrderTypes] = None class ListActiveGuildThreadsResponse(BaseModel): @@ -1979,8 +1976,8 @@ class ListActiveGuildThreadsResponse(BaseModel): see https://discord.com/developers/docs/resources/guild#list-active-guild-threads""" - threads: List[Channel] - members: List[ThreadMember] + threads: list[Channel] + members: list[ThreadMember] class ModifyGuildWelcomeScreenParams(BaseModel): @@ -1989,9 +1986,9 @@ class ModifyGuildWelcomeScreenParams(BaseModel): see https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen """ - enabled: Optional[bool] - welcome_channels: Optional[List[WelcomeScreenChannel]] - description: Optional[str] + enabled: Optional[bool] = None + welcome_channels: Optional[list[WelcomeScreenChannel]] = None + description: Optional[str] = None # Guild Scheduled Event @@ -2006,17 +2003,17 @@ class GuildScheduledEvent(BaseModel): id: Snowflake guild_id: Snowflake - channel_id: Optional[Snowflake] + channel_id: Optional[Snowflake] = None creator_id: MissingOrNullable[Snowflake] = UNSET name: str description: MissingOrNullable[str] = UNSET scheduled_start_time: datetime.datetime - scheduled_end_time: Optional[datetime.datetime] + scheduled_end_time: Optional[datetime.datetime] = None privacy_level: GuildScheduledEventPrivacyLevel status: GuildScheduledEventStatus entity_type: GuildScheduledEventEntityType - entity_id: Optional[Snowflake] - entity_metadata: Optional["GuildScheduledEventEntityMetadata"] + entity_id: Optional[Snowflake] = None + entity_metadata: Optional["GuildScheduledEventEntityMetadata"] = None creator: Missing["User"] = UNSET user_count: Missing[int] = UNSET image: MissingOrNullable[str] = UNSET @@ -2048,15 +2045,15 @@ class CreateGuildScheduledEventParams(BaseModel): see https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event-json-params """ - channel_id: Optional[Snowflake] - entity_metadata: Optional[GuildScheduledEventEntityMetadata] + channel_id: Optional[Snowflake] = None + entity_metadata: Optional[GuildScheduledEventEntityMetadata] = None name: str privacy_level: GuildScheduledEventPrivacyLevel scheduled_start_time: datetime.datetime # ISO8601 timestamp - scheduled_end_time: Optional[datetime.datetime] # ISO8601 timestamp - description: Optional[str] + scheduled_end_time: Optional[datetime.datetime] = None # ISO8601 timestamp + description: Optional[str] = None entity_type: GuildScheduledEventEntityType - image: Optional[str] + image: Optional[str] = None class ModifyGuildScheduledEventParams(BaseModel): @@ -2065,16 +2062,16 @@ class ModifyGuildScheduledEventParams(BaseModel): see https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event-json-params """ - channel_id: Optional[Snowflake] - entity_metadata: Optional[GuildScheduledEventEntityMetadata] - name: Optional[str] - privacy_level: Optional[GuildScheduledEventPrivacyLevel] - scheduled_start_time: Optional[datetime.datetime] # ISO8601 timestamp - scheduled_end_time: Optional[datetime.datetime] # ISO8601 timestamp - description: Optional[str] - entity_type: Optional[GuildScheduledEventEntityType] - status: Optional[GuildScheduledEventStatus] - image: Optional[str] + channel_id: Optional[Snowflake] = None + entity_metadata: Optional[GuildScheduledEventEntityMetadata] = None + name: Optional[str] = None + privacy_level: Optional[GuildScheduledEventPrivacyLevel] = None + scheduled_start_time: Optional[datetime.datetime] = None # ISO8601 timestamp + scheduled_end_time: Optional[datetime.datetime] = None # ISO8601 timestamp + description: Optional[str] = None + entity_type: Optional[GuildScheduledEventEntityType] = None + status: Optional[GuildScheduledEventStatus] = None + image: Optional[str] = None # Guild Template @@ -2087,7 +2084,7 @@ class GuildTemplate(BaseModel): code: str name: str - description: Optional[str] + description: Optional[str] = None usage_count: int creator_id: str creator: "User" @@ -2095,7 +2092,7 @@ class GuildTemplate(BaseModel): updated_at: datetime.datetime source_guild_id: Snowflake serialized_source_guild: "Guild" # partial guild object - is_dirty: Optional[bool] + is_dirty: Optional[bool] = None # Invite @@ -2138,7 +2135,7 @@ class InviteStageInstance(BaseModel): see https://discord.com/developers/docs/resources/invite#invite-stage-instance-object """ - members: List[GuildMember] # partial guild member objects + members: list[GuildMember] # partial guild member objects participant_count: int speaker_count: int topic: str @@ -2160,7 +2157,7 @@ class StageInstance(BaseModel): topic: str privacy_level: StagePrivacyLevel discoverable_disabled: bool - guild_scheduled_event_id: Optional[Snowflake] + guild_scheduled_event_id: Optional[Snowflake] = None # Sticker @@ -2200,7 +2197,7 @@ class StickerPack(BaseModel): see https://discord.com/developers/docs/resources/sticker#sticker-pack-object""" id: Snowflake - stickers: List[Sticker] + stickers: list[Sticker] name: str sku_id: Snowflake cover_sticker_id: Missing[Snowflake] = UNSET @@ -2218,7 +2215,7 @@ class User(BaseModel): id: Snowflake username: str discriminator: str - global_name: Optional[str] + global_name: Optional[str] = None avatar: Optional[str] = Field(...) bot: Missing[bool] = UNSET system: Missing[bool] = UNSET @@ -2243,7 +2240,7 @@ class Connection(BaseModel): name: str type: ConnectionServiceType revoked: Missing[bool] = UNSET - integrations: Missing[List["Integration"]] = UNSET + integrations: Missing[list["Integration"]] = UNSET verified: bool friend_sync: bool show_activity: bool @@ -2339,11 +2336,11 @@ class ExecuteWebhookParams(BaseModel): username: Optional[str] = None avatar_url: Optional[str] = None tts: Optional[bool] = None - embeds: Optional[List[Embed]] = None + embeds: Optional[list[Embed]] = None allowed_mentions: Optional[AllowedMention] = None - components: Optional[List[DirectComponent]] = None - files: Optional[List[File]] = None - attachments: Optional[List[AttachmentSend]] = None + components: Optional[list[DirectComponent]] = None + files: Optional[list[File]] = None + attachments: Optional[list[AttachmentSend]] = None flags: Optional[MessageFlag] = None thread_name: Optional[str] = None @@ -2392,7 +2389,7 @@ class Identify(BaseModel): properties: "IdentifyConnectionProperties" compress: Missing[bool] = UNSET large_threshold: Missing[int] = UNSET - shard: Missing[List[int]] = UNSET + shard: Missing[list[int]] = UNSET presence: Missing["PresenceUpdate"] = UNSET intents: int @@ -2428,7 +2425,7 @@ class RequestGuildMembers(BaseModel): query: Missing[str] = UNSET limit: int presences: Missing[bool] = UNSET - user_ids: Missing[Union[Snowflake, List[Snowflake]]] = UNSET + user_ids: Missing[Union[Snowflake, list[Snowflake]]] = UNSET nonce: Missing[str] = UNSET @@ -2449,7 +2446,7 @@ class UpdatePresence(BaseModel): see https://discord.com/developers/docs/topics/gateway-events#update-presence""" since: Optional[int] = Field(...) - activities: List["Activity"] + activities: list["Activity"] status: UpdatePresenceStatusType afk: bool @@ -2476,10 +2473,10 @@ class Ready(BaseModel): v: int user: User - guilds: List[UnavailableGuild] + guilds: list[UnavailableGuild] session_id: str resume_gateway_url: str - shard: Missing[List[int]] = UNSET + shard: Missing[list[int]] = UNSET application: ApplicationReady @@ -2574,9 +2571,9 @@ class ThreadListSync(BaseModel): """ guild_id: Snowflake - channel_ids: Missing[List[Snowflake]] = UNSET - threads: List[Channel] - members: List[ThreadMember] + channel_ids: Missing[list[Snowflake]] = UNSET + threads: list[Channel] + members: list[ThreadMember] class ThreadMemberUpdate(ThreadMember): @@ -2597,8 +2594,8 @@ class ThreadMembersUpdate(BaseModel): id: Snowflake guild_id: Snowflake member_count: int - added_members: Missing[List[ThreadMember]] = UNSET - removed_member_ids: Missing[List[Snowflake]] = UNSET + added_members: Missing[list[ThreadMember]] = UNSET + removed_member_ids: Missing[list[Snowflake]] = UNSET class ChannelPinsUpdate(BaseModel): @@ -2634,9 +2631,9 @@ class GuildCreate(BaseModel): verification_level: Missing[VerificationLevel] = UNSET default_message_notifications: Missing[DefaultMessageNotificationLevel] = UNSET explicit_content_filter: Missing[ExplicitContentFilterLevel] = UNSET - roles: Missing[List["Role"]] = UNSET - emojis: Missing[List[Emoji]] = UNSET - features: Missing[List[GuildFeature]] = UNSET + roles: Missing[list["Role"]] = UNSET + emojis: Missing[list[Emoji]] = UNSET + features: Missing[list[GuildFeature]] = UNSET mfa_level: Missing[MFALevel] = UNSET application_id: MissingOrNullable[Snowflake] = UNSET system_channel_id: MissingOrNullable[Snowflake] = UNSET @@ -2657,20 +2654,20 @@ class GuildCreate(BaseModel): approximate_presence_count: Missing[int] = UNSET welcome_screen: Missing[WelcomeScreen] = UNSET nsfw_level: Missing[GuildNSFWLevel] = UNSET - stickers: Missing[List[Sticker]] = UNSET + stickers: Missing[list[Sticker]] = UNSET premium_progress_bar_enabled: Missing[bool] = UNSET joined_at: Missing[str] = UNSET large: Missing[bool] = UNSET member_count: Missing[int] = UNSET - voice_states: Missing[List["VoiceState"]] = UNSET - members: Missing[List["GuildMember"]] = UNSET - channels: Missing[List["Channel"]] = UNSET - threads: Missing[List["Channel"]] = UNSET - presences: Missing[List["PresenceUpdate"]] = ( + voice_states: Missing[list["VoiceState"]] = UNSET + members: Missing[list["GuildMember"]] = UNSET + channels: Missing[list["Channel"]] = UNSET + threads: Missing[list["Channel"]] = UNSET + presences: Missing[list["PresenceUpdate"]] = ( UNSET # partial presence update objects ) - stage_instances: Missing[List["StageInstance"]] = UNSET - guild_scheduled_events: Missing[List["GuildScheduledEvent"]] = UNSET + stage_instances: Missing[list["StageInstance"]] = UNSET + guild_scheduled_events: Missing[list["GuildScheduledEvent"]] = UNSET class GuildUpdate(Guild): @@ -2716,7 +2713,7 @@ class GuildEmojisUpdate(BaseModel): see https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update""" guild_id: Snowflake - emojis: List[Emoji] + emojis: list[Emoji] class GuildStickersUpdate(BaseModel): @@ -2726,7 +2723,7 @@ class GuildStickersUpdate(BaseModel): """ guild_id: Snowflake - stickers: List[Sticker] + stickers: list[Sticker] class GuildIntegrationsUpdate(BaseModel): @@ -2761,7 +2758,7 @@ class GuildMemberUpdate(BaseModel): see https://discord.com/developers/docs/topics/gateway-events#guild-member-update""" guild_id: Snowflake - roles: List[Snowflake] + roles: list[Snowflake] user: User nick: MissingOrNullable[str] = UNSET joined_at: Optional[datetime.datetime] = Field(...) @@ -2778,11 +2775,11 @@ class GuildMembersChunk(BaseModel): see https://discord.com/developers/docs/topics/gateway-events#guild-members-chunk""" guild_id: Snowflake - members: List[GuildMember] + members: list[GuildMember] chunk_index: int chunk_count: int - not_found: Missing[List[Snowflake]] = UNSET - presences: Missing[List["PresenceUpdate"]] = UNSET + not_found: Missing[list[Snowflake]] = UNSET + presences: Missing[list["PresenceUpdate"]] = UNSET nonce: Missing[str] = UNSET @@ -2921,7 +2918,7 @@ class MessageCreate(MessageGet): guild_id: Missing[Snowflake] = UNSET member: Missing[GuildMember] = UNSET # partial member object - mentions: List[User] + mentions: list[User] class MessageUpdate(MessageGet): @@ -2935,7 +2932,7 @@ class MessageUpdate(MessageGet): guild_id: Missing[str] = UNSET member: Missing[GuildMember] = UNSET - mentions: Missing[List[User]] = UNSET + mentions: Missing[list[User]] = UNSET id: Snowflake channel_id: Snowflake author: Missing["User"] = UNSET @@ -2944,11 +2941,11 @@ class MessageUpdate(MessageGet): edited_timestamp: MissingOrNullable[datetime.datetime] = UNSET tts: Missing[bool] = UNSET mention_everyone: Missing[bool] = UNSET - mention_roles: Missing[List[str]] = UNSET - mention_channels: Missing[List["ChannelMention"]] = UNSET - attachments: Missing[List["Attachment"]] = UNSET - embeds: Missing[List["Embed"]] = UNSET - reactions: Missing[List["Reaction"]] = UNSET + mention_roles: Missing[list[str]] = UNSET + mention_channels: Missing[list["ChannelMention"]] = UNSET + attachments: Missing[list["Attachment"]] = UNSET + embeds: Missing[list["Embed"]] = UNSET + reactions: Missing[list["Reaction"]] = UNSET nonce: Missing[Union[int, str]] = UNSET pinned: Missing[bool] = UNSET webhook_id: Missing[Snowflake] = UNSET @@ -2961,9 +2958,9 @@ class MessageUpdate(MessageGet): referenced_message: MissingOrNullable["MessageGet"] = UNSET interaction: Missing[MessageInteraction] = UNSET thread: Missing[Channel] = UNSET - components: Missing[List[DirectComponent]] = UNSET - sticker_items: Missing[List["StickerItem"]] = UNSET - stickers: Missing[List["Sticker"]] = UNSET + components: Missing[list[DirectComponent]] = UNSET + sticker_items: Missing[list["StickerItem"]] = UNSET + stickers: Missing[list["Sticker"]] = UNSET position: Missing[int] = UNSET role_subscription_data: Missing["RoleSubscriptionData"] = UNSET @@ -2985,7 +2982,7 @@ class MessageDeleteBulk(BaseModel): see https://discord.com/developers/docs/topics/gateway-events#message-delete-bulk """ - ids: List[Snowflake] + ids: list[Snowflake] channel_id: Snowflake guild_id: Missing[Snowflake] = UNSET @@ -3071,7 +3068,7 @@ class PresenceUpdate(BaseModel): user: PresenceUpdateUser guild_id: Missing[Snowflake] = UNSET status: PresenceStatus - activities: List["Activity"] + activities: list["Activity"] client_status: "ClientStatus" @@ -3105,7 +3102,7 @@ class Activity(BaseModel): secrets: Missing["ActivitySecrets"] = UNSET instance: Missing[bool] = UNSET flags: Missing[ActivityFlags] = UNSET - buttons: Missing[List["ActivityButtons"]] = UNSET + buttons: Missing[list["ActivityButtons"]] = UNSET class ActivityTimestamps(BaseModel): @@ -3136,7 +3133,7 @@ class ActivityParty(BaseModel): """ id: Missing[str] = UNSET - size: Missing[Tuple[int, int]] = UNSET + size: Missing[tuple[int, int]] = UNSET class ActivityAssets(BaseModel): @@ -3303,7 +3300,7 @@ class Team(BaseModel): icon: Optional[str] = Field(...) id: str - members: List["TeamMember"] + members: list["TeamMember"] name: str owner_user_id: Snowflake @@ -3315,7 +3312,7 @@ class TeamMember(BaseModel): """ membership_state: MembershipState - permissions: List[str] + permissions: list[str] team_id: Snowflake user: "TeamMemberUser" @@ -3323,7 +3320,7 @@ class TeamMember(BaseModel): class TeamMemberUser(BaseModel): """partial user object for TeamMember""" - avatar: Optional[str] + avatar: Optional[str] = None discriminator: str id: Snowflake username: str @@ -3336,7 +3333,7 @@ class AuthorizationResponse(BaseModel): """ application: Application # partial application object - scopes: List[str] + scopes: list[str] expires: datetime.datetime user: Missing[User] = UNSET diff --git a/nonebot/adapters/discord/api/types.py b/nonebot/adapters/discord/api/types.py index cce48af..7542344 100644 --- a/nonebot/adapters/discord/api/types.py +++ b/nonebot/adapters/discord/api/types.py @@ -1,7 +1,12 @@ from enum import Enum, IntEnum, IntFlag -from typing import Any, Dict, Literal, TypeVar, Union, final +from typing import Any, Literal, TypeVar, Union, final from typing_extensions import TypeAlias +from nonebot.compat import PYDANTIC_V2 + +if PYDANTIC_V2: + from pydantic_core import core_schema + T = TypeVar("T") @@ -21,12 +26,23 @@ def __bool__(self) -> Literal[False]: def __copy__(self): return self._UNSET - def __deepcopy__(self, memo: Dict[int, Any]): + def __deepcopy__(self, memo: dict[int, Any]): return self._UNSET - @classmethod - def __get_validators__(cls): - yield cls._validate + if PYDANTIC_V2: + + @classmethod + def __get_pydantic_core_schema__( + cls, source_type: Any, handler: Any + ) -> core_schema.CoreSchema: + return core_schema.with_info_plain_validator_function( + lambda value, _: cls._validate(value) + ) + else: + + @classmethod + def __get_validators__(cls): + yield cls._validate @classmethod def _validate(cls, value: Any): diff --git a/nonebot/adapters/discord/api/utils.py b/nonebot/adapters/discord/api/utils.py index a33fa08..2d1bf17 100644 --- a/nonebot/adapters/discord/api/utils.py +++ b/nonebot/adapters/discord/api/utils.py @@ -1,5 +1,5 @@ import json -from typing import Any, Dict, List, Literal, Type, Union +from typing import Any, Literal, Union from nonebot.compat import type_validate_python @@ -13,13 +13,13 @@ def parse_data( - data: Dict[str, Any], model_class: Type[Union[MessageSend, ExecuteWebhookParams]] -) -> Dict[Literal["files", "json"], Any]: + data: dict[str, Any], model_class: type[Union[MessageSend, ExecuteWebhookParams]] +) -> dict[Literal["files", "json"], Any]: model = type_validate_python(model_class, data) - payload: Dict[str, Any] = model_dump(model, exclude={"files"}, exclude_none=True) + payload: dict[str, Any] = model_dump(model, exclude={"files"}, exclude_none=True) if model.files: - multipart: Dict[str, Any] = {} - attachments: List[dict] = payload.pop("attachments", []) + multipart: dict[str, Any] = {} + attachments: list[dict] = payload.pop("attachments", []) for index, file in enumerate(model.files): for attachment in attachments: if attachment["filename"] == file.filename: @@ -35,11 +35,11 @@ def parse_data( def parse_forum_thread_message( - data: Dict[str, Any], -) -> Dict[Literal["files", "json"], Any]: + data: dict[str, Any], +) -> dict[Literal["files", "json"], Any]: model = type_validate_python(MessageSend, data) - payload: Dict[str, Any] = {} - content: Dict[str, Any] = model_dump(model, exclude={"files"}, exclude_none=True) + payload: dict[str, Any] = {} + content: dict[str, Any] = model_dump(model, exclude={"files"}, exclude_none=True) if auto_archive_duration := data.pop("auto_archive_duration"): payload["auto_archive_duration"] = auto_archive_duration if rate_limit_per_user := data.pop("rate_limit_per_user"): @@ -48,7 +48,7 @@ def parse_forum_thread_message( payload["applied_tags"] = applied_tags payload["message"] = content if model.files: - multipart: Dict[str, Any] = {"payload_json": None} + multipart: dict[str, Any] = {"payload_json": None} attachments: list[dict] = payload.pop("attachments", []) for index, file in enumerate(model.files): for attachment in attachments: @@ -66,15 +66,15 @@ def parse_forum_thread_message( def parse_interaction_response( response: InteractionResponse, -) -> Dict[Literal["files", "json"], Any]: - payload: Dict[str, Any] = model_dump(response, exclude_none=True) +) -> dict[Literal["files", "json"], Any]: + payload: dict[str, Any] = model_dump(response, exclude_none=True) if response.data and isinstance(response.data, InteractionCallbackMessage): payload["data"] = model_dump( response.data, exclude={"files"}, exclude_none=True ) if response.data.files: - multipart: Dict[str, Any] = {} - attachments: List[dict] = payload["data"].pop("attachments", []) + multipart: dict[str, Any] = {} + attachments: list[dict] = payload["data"].pop("attachments", []) for index, file in enumerate(response.data.files): for attachment in attachments: if attachment["filename"] == file.filename: diff --git a/nonebot/adapters/discord/commands/matcher.py b/nonebot/adapters/discord/commands/matcher.py index 91f4c24..2ef6732 100644 --- a/nonebot/adapters/discord/commands/matcher.py +++ b/nonebot/adapters/discord/commands/matcher.py @@ -1,5 +1,6 @@ +from collections.abc import Iterable from datetime import datetime, timedelta -from typing import Any, Dict, Iterable, List, Optional, Type, Union +from typing import Any, Optional, Union from nonebot.adapters import MessageTemplate from nonebot.dependencies import Dependent @@ -53,7 +54,7 @@ class ApplicationCommandConfig(ApplicationCommandCreate): - guild_ids: Optional[List[Snowflake]] = None + guild_ids: Optional[list[Snowflake]] = None # def _application_command_rule(event: ApplicationCommandInteractionEvent) -> bool: @@ -316,25 +317,25 @@ class UserMessageCommandMatcher(ApplicationCommandMatcher): def on_slash_command( name: str, description: str, - options: Optional[List[AnyCommandOption]] = None, + options: Optional[list[AnyCommandOption]] = None, internal_id: Optional[str] = None, rule: Union[Rule, T_RuleChecker, None] = None, permission: Union[Permission, T_PermissionChecker, None] = None, *, - name_localizations: Optional[Dict[str, str]] = None, - description_localizations: Optional[Dict[str, str]] = None, + name_localizations: Optional[dict[str, str]] = None, + description_localizations: Optional[dict[str, str]] = None, default_member_permissions: Optional[str] = None, dm_permission: Optional[bool] = None, default_permission: Optional[bool] = None, nsfw: Optional[bool] = None, - handlers: Optional[List[Union[T_Handler, Dependent]]] = None, + handlers: Optional[list[Union[T_Handler, Dependent]]] = None, temp: bool = False, expire_time: Union[datetime, timedelta, None] = None, priority: int = 1, block: bool = True, state: Optional[T_State] = None, _depth: int = 0, -) -> Type[SlashCommandMatcher]: +) -> type[SlashCommandMatcher]: config = ApplicationCommandConfig( type=ApplicationCommandType.CHAT_INPUT, name=name, @@ -348,7 +349,7 @@ def on_slash_command( nsfw=nsfw, ) _application_command_storage[internal_id or name] = config - matcher: Type[SlashCommandMatcher] = SlashCommandMatcher.new( + matcher: type[SlashCommandMatcher] = SlashCommandMatcher.new( "notice", Rule() & rule, Permission() | permission, @@ -388,19 +389,19 @@ def on_user_command( rule: Union[Rule, T_RuleChecker, None] = None, permission: Union[Permission, T_PermissionChecker, None] = None, *, - name_localizations: Optional[Dict[str, str]] = None, + name_localizations: Optional[dict[str, str]] = None, default_member_permissions: Optional[str] = None, dm_permission: Optional[bool] = None, default_permission: Optional[bool] = None, nsfw: Optional[bool] = None, - handlers: Optional[List[Union[T_Handler, Dependent]]] = None, + handlers: Optional[list[Union[T_Handler, Dependent]]] = None, temp: bool = False, expire_time: Union[datetime, timedelta, None] = None, priority: int = 1, block: bool = True, state: Optional[T_State] = None, _depth: int = 0, -) -> Type[UserMessageCommandMatcher]: +) -> type[UserMessageCommandMatcher]: config = ApplicationCommandConfig( type=ApplicationCommandType.USER, name=name, @@ -411,7 +412,7 @@ def on_user_command( nsfw=nsfw, ) _application_command_storage[internal_id or name] = config - matcher: Type[UserMessageCommandMatcher] = UserMessageCommandMatcher.new( + matcher: type[UserMessageCommandMatcher] = UserMessageCommandMatcher.new( "notice", Rule() & rule, Permission() | permission, @@ -451,19 +452,19 @@ def on_message_command( rule: Union[Rule, T_RuleChecker, None] = None, permission: Union[Permission, T_PermissionChecker, None] = None, *, - name_localizations: Optional[Dict[str, str]] = None, + name_localizations: Optional[dict[str, str]] = None, default_member_permissions: Optional[str] = None, dm_permission: Optional[bool] = None, default_permission: Optional[bool] = None, nsfw: Optional[bool] = None, - handlers: Optional[List[Union[T_Handler, Dependent]]] = None, + handlers: Optional[list[Union[T_Handler, Dependent]]] = None, temp: bool = False, expire_time: Union[datetime, timedelta, None] = None, priority: int = 1, block: bool = True, state: Optional[T_State] = None, _depth: int = 0, -) -> Type[UserMessageCommandMatcher]: +) -> type[UserMessageCommandMatcher]: config = ApplicationCommandConfig( type=ApplicationCommandType.MESSAGE, name=name, @@ -474,7 +475,7 @@ def on_message_command( nsfw=nsfw, ) _application_command_storage[internal_id or name] = config - matcher: Type[UserMessageCommandMatcher] = UserMessageCommandMatcher.new( + matcher: type[UserMessageCommandMatcher] = UserMessageCommandMatcher.new( "notice", Rule() & rule, Permission() | permission, diff --git a/nonebot/adapters/discord/commands/params.py b/nonebot/adapters/discord/commands/params.py index 22b136d..9cc70bf 100644 --- a/nonebot/adapters/discord/commands/params.py +++ b/nonebot/adapters/discord/commands/params.py @@ -1,6 +1,6 @@ import inspect -from typing import Any, Optional, Tuple, Type, TypeVar -from typing_extensions import Annotated, get_args, get_origin, override +from typing import Annotated, Any, Optional, TypeVar +from typing_extensions import get_args, get_origin, override from nonebot.dependencies import Param from nonebot.params import Depends @@ -43,7 +43,7 @@ def __repr__(self) -> str: @classmethod @override def _check_param( - cls, param: inspect.Parameter, allow_types: Tuple[Type[Param], ...] + cls, param: inspect.Parameter, allow_types: tuple[type[Param], ...] ) -> Optional["OptionParam"]: if isinstance(param.default, CommandOptionType): return cls(key=param.default.key or param.name, validate=True) diff --git a/nonebot/adapters/discord/commands/storage.py b/nonebot/adapters/discord/commands/storage.py index 44aee2f..23bf7c3 100644 --- a/nonebot/adapters/discord/commands/storage.py +++ b/nonebot/adapters/discord/commands/storage.py @@ -1,5 +1,5 @@ from collections import defaultdict -from typing import TYPE_CHECKING, Dict, List, Literal +from typing import TYPE_CHECKING, Literal from ..api import ApplicationCommandCreate, Snowflake from ..bot import Bot @@ -8,7 +8,7 @@ if TYPE_CHECKING: from .matcher import ApplicationCommandConfig -_application_command_storage: Dict[str, "ApplicationCommandConfig"] = {} +_application_command_storage: dict[str, "ApplicationCommandConfig"] = {} OPTION_KEY: Literal["_discord_application_command_options"] = ( "_discord_application_command_options" @@ -16,8 +16,8 @@ async def sync_application_command(bot: Bot): - commands_global: List[ApplicationCommandCreate] = [] - commands_guild: Dict[Snowflake, List[ApplicationCommandCreate]] = defaultdict(List) + commands_global: list[ApplicationCommandCreate] = [] + commands_guild: dict[Snowflake, list[ApplicationCommandCreate]] = defaultdict(list) if "*" in bot.bot_info.application_commands: if "*" in bot.bot_info.application_commands["*"]: commands_global = [ diff --git a/nonebot/adapters/discord/config.py b/nonebot/adapters/discord/config.py index 6080284..d267197 100644 --- a/nonebot/adapters/discord/config.py +++ b/nonebot/adapters/discord/config.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Literal, Optional, Tuple, Union +from typing import Literal, Optional, Union from pydantic import BaseModel, Field @@ -52,15 +52,15 @@ def to_int(self): class BotInfo(BaseModel): token: str - shard: Optional[Tuple[int, int]] = None + shard: Optional[tuple[int, int]] = None intent: Intents = Field(default_factory=Intents) - application_commands: Dict[str, List[Union[Literal["*"], Snowflake]]] = Field( + application_commands: dict[str, list[Union[Literal["*"], Snowflake]]] = Field( default_factory=dict ) class Config(BaseModel): - discord_bots: List[BotInfo] = Field(default_factory=list) + discord_bots: list[BotInfo] = Field(default_factory=list) discord_compress: bool = False discord_api_version: int = 10 discord_api_timeout: float = 30.0 diff --git a/nonebot/adapters/discord/event.py b/nonebot/adapters/discord/event.py index e9ba262..5756bb3 100644 --- a/nonebot/adapters/discord/event.py +++ b/nonebot/adapters/discord/event.py @@ -1,6 +1,6 @@ from datetime import datetime from enum import Enum -from typing import Dict, List, Literal, Optional, Type, Union +from typing import Literal, Optional, Union from typing_extensions import override from nonebot.adapters import Event as BaseEvent @@ -280,7 +280,7 @@ class ApplicationCommandPermissionsUpdateEvent(NoticeEvent): id: Snowflake application_id: Snowflake guild_id: Snowflake - permissions: List[ApplicationCommandPermissions] + permissions: list[ApplicationCommandPermissions] class AutoModerationEvent(NoticeEvent): @@ -905,7 +905,7 @@ class WebhooksUpdateEvent(NoticeEvent, WebhooksUpdate): __type__ = EventType.WEBHOOKS_UPDATE -event_classes: Dict[str, Type[Event]] = { +event_classes: dict[str, type[Event]] = { EventType.HELLO.value: HelloEvent, EventType.READY.value: ReadyEvent, EventType.RESUMED.value: ResumedEvent, diff --git a/nonebot/adapters/discord/message.py b/nonebot/adapters/discord/message.py index 8cea3c7..3afac43 100644 --- a/nonebot/adapters/discord/message.py +++ b/nonebot/adapters/discord/message.py @@ -1,14 +1,12 @@ +from collections.abc import Iterable from dataclasses import dataclass import datetime import re from typing import ( TYPE_CHECKING, Any, - Dict, - Iterable, Literal, Optional, - Type, TypedDict, Union, overload, @@ -42,7 +40,7 @@ class MessageSegment(BaseMessageSegment["Message"]): @classmethod @override - def get_message_class(cls) -> Type["Message"]: + def get_message_class(cls) -> type["Message"]: return Message @staticmethod @@ -371,7 +369,7 @@ def __str__(self): class Message(BaseMessage[MessageSegment]): @classmethod @override - def get_segment_class(cls) -> Type[MessageSegment]: + def get_segment_class(cls) -> type[MessageSegment]: return MessageSegment @override @@ -476,7 +474,7 @@ def extract_content(self) -> str: ) -def parse_message(message: Union[Message, MessageSegment, str]) -> Dict[str, Any]: +def parse_message(message: Union[Message, MessageSegment, str]) -> dict[str, Any]: message = MessageSegment.text(message) if isinstance(message, str) else message message = message if isinstance(message, Message) else Message(message) diff --git a/nonebot/adapters/discord/payload.py b/nonebot/adapters/discord/payload.py index bf6e452..3b7f1d4 100644 --- a/nonebot/adapters/discord/payload.py +++ b/nonebot/adapters/discord/payload.py @@ -1,6 +1,6 @@ from enum import IntEnum -from typing import Optional, Union -from typing_extensions import Annotated, Literal +from typing import Annotated, Optional, Union +from typing_extensions import Literal from nonebot.compat import PYDANTIC_V2, ConfigDict @@ -44,7 +44,7 @@ class Dispatch(Payload): class Heartbeat(Payload): opcode: Literal[Opcode.HEARTBEAT] = Field(Opcode.HEARTBEAT, alias="op") - data: Optional[int] = Field(alias="d") + data: Optional[int] = Field(None, alias="d") class Identify(Payload): diff --git a/nonebot/adapters/discord/utils.py b/nonebot/adapters/discord/utils.py index 9ca221e..6b98293 100644 --- a/nonebot/adapters/discord/utils.py +++ b/nonebot/adapters/discord/utils.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Set, Union +from typing import Any, Optional, Union import zlib from nonebot.compat import model_dump as model_dump_ @@ -25,13 +25,13 @@ def exclude_unset_data(data: Any) -> Any: def model_dump( model: BaseModel, - include: Optional[Set[str]] = None, - exclude: Optional[Set[str]] = None, + include: Optional[set[str]] = None, + exclude: Optional[set[str]] = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, -) -> Dict[str, Any]: +) -> dict[str, Any]: data = model_dump_( model, include=include, diff --git a/poetry.lock b/poetry.lock index 7818344..935a9a5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" @@ -11,9 +11,6 @@ files = [ {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} - [[package]] name = "cfgv" version = "3.4.0" @@ -482,6 +479,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -730,5 +728,5 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "a89de6111fc8bc11aeee1ddf369243ce7629af37ab359db592aec28b384baf12" +python-versions = "^3.9" +content-hash = "29744f37bcf599639e032a52daca4184c4bd2a3009048ff953428c563d9afc13" diff --git a/pyproject.toml b/pyproject.toml index 3ae5efb..d7eb4a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ keywords = ["nonebot", "discord", "bot"] packages = [{ include = "nonebot" }] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" nonebot2 = "^2.2.1" [tool.poetry.group.dev.dependencies] @@ -25,7 +25,7 @@ pre-commit = "^3.1.0" select = ["E", "W", "F", "I", "UP", "C", "T", "PYI", "PT"] ignore = ["E402", "F403", "F405", "C901", "PYI021", "PYI048", "W191", "E501"] line-length = 88 -target-version = "py38" +target-version = "py39" ignore-init-module-imports = true