diff --git a/discord/client.py b/discord/client.py index adbfb2583..67e42410b 100644 --- a/discord/client.py +++ b/discord/client.py @@ -83,7 +83,7 @@ from .soundboard import SoundboardDefaultSound, SoundboardSound if TYPE_CHECKING: from types import TracebackType - from typing_extensions import Self, NotRequired, Unpack + from typing_extensions import Self, Unpack from .abc import Messageable, PrivateChannel, Snowflake, SnowflakeTime from .app_commands import Command, ContextMenu @@ -123,26 +123,26 @@ if TYPE_CHECKING: from .subscription import Subscription from .flags import MemberCacheFlags - class _ClientOptions(TypedDict): - max_messages: NotRequired[Optional[int]] - proxy: NotRequired[Optional[str]] - proxy_auth: NotRequired[Optional[aiohttp.BasicAuth]] - shard_id: NotRequired[Optional[int]] - shard_count: NotRequired[Optional[int]] - application_id: NotRequired[int] - member_cache_flags: NotRequired[MemberCacheFlags] - chunk_guilds_at_startup: NotRequired[bool] - status: NotRequired[Optional[Status]] - activity: NotRequired[Optional[BaseActivity]] - allowed_mentions: NotRequired[Optional[AllowedMentions]] - heartbeat_timeout: NotRequired[float] - guild_ready_timeout: NotRequired[float] - assume_unsync_clock: NotRequired[bool] - enable_debug_events: NotRequired[bool] - enable_raw_presences: NotRequired[bool] - http_trace: NotRequired[Optional[aiohttp.TraceConfig]] - max_ratelimit_timeout: NotRequired[Optional[float]] - connector: NotRequired[Optional[aiohttp.BaseConnector]] + class _ClientOptions(TypedDict, total=False): + max_messages: int + proxy: str + proxy_auth: aiohttp.BasicAuth + shard_id: int + shard_count: int + application_id: int + member_cache_flags: MemberCacheFlags + chunk_guilds_at_startup: bool + status: Status + activity: BaseActivity + allowed_mentions: AllowedMentions + heartbeat_timeout: float + guild_ready_timeout: float + assume_unsync_clock: bool + enable_debug_events: bool + enable_raw_presences: bool + http_trace: aiohttp.TraceConfig + max_ratelimit_timeout: float + connector: aiohttp.BaseConnector # fmt: off diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 005a25377..29b1f045e 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -64,7 +64,7 @@ from .cog import Cog from .hybrid import hybrid_command, hybrid_group, HybridCommand, HybridGroup if TYPE_CHECKING: - from typing_extensions import Self, Unpack, NotRequired + from typing_extensions import Self, Unpack import importlib.machinery @@ -88,11 +88,11 @@ if TYPE_CHECKING: _PrefixCallable = MaybeAwaitableFunc[[BotT, Message], _Prefix] PrefixType = Union[_Prefix, _PrefixCallable[BotT]] - class _BotOptions(_ClientOptions): - owner_id: NotRequired[Optional[int]] - owner_ids: NotRequired[Optional[Collection[int]]] - strip_after_prefix: NotRequired[bool] - case_insensitive: NotRequired[bool] + class _BotOptions(_ClientOptions, total=False): + owner_id: int + owner_ids: Collection[int] + strip_after_prefix: bool + case_insensitive: bool class _AutoShardedBotOptions(_AutoShardedClientOptions, _BotOptions): ... diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 48069dd85..1b8a24e66 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -50,7 +50,7 @@ from typing import ( from ._types import _BaseCommand, BotT if TYPE_CHECKING: - from typing_extensions import Self, Unpack, NotRequired + from typing_extensions import Self, Unpack from discord.abc import Snowflake from discord._types import ClientT @@ -58,15 +58,15 @@ if TYPE_CHECKING: from .context import Context from .core import Command, _CommandDecoratorKwargs - class _CogKwargs(TypedDict): - name: NotRequired[Optional[str]] - group_name: NotRequired[Optional[Union[str, app_commands.locale_str]]] - description: NotRequired[Optional[str]] - group_description: NotRequired[Optional[Union[str, app_commands.locale_str]]] - group_nsfw: NotRequired[bool] - group_auto_locale_strings: NotRequired[bool] - group_extras: NotRequired[Dict[Any, Any]] - command_attrs: NotRequired[_CommandDecoratorKwargs] + class _CogKwargs(TypedDict, total=False): + name: str + group_name: Union[str, app_commands.locale_str] + description: str + group_description: Union[str, app_commands.locale_str] + group_nsfw: bool + group_auto_locale_strings: bool + group_extras: Dict[Any, Any] + command_attrs: _CommandDecoratorKwargs __all__ = ( diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index d0db462ac..9107a3d22 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -59,38 +59,38 @@ from .parameters import Parameter, Signature from discord.app_commands.commands import NUMPY_DOCSTRING_ARG_REGEX if TYPE_CHECKING: - from typing_extensions import Concatenate, ParamSpec, Self, NotRequired, Unpack + from typing_extensions import Concatenate, ParamSpec, Self, Unpack from ._types import BotT, Check, ContextT, Coro, CoroFunc, Error, Hook, UserCheck from discord.permissions import _PermissionsKwargs - class _CommandDecoratorKwargs(TypedDict): - enabled: NotRequired[bool] - help: NotRequired[str] - brief: NotRequired[str] - usage: NotRequired[str] - rest_is_raw: NotRequired[bool] - aliases: NotRequired[List[str]] - description: NotRequired[str] - hidden: NotRequired[bool] - checks: NotRequired[List[UserCheck[Context[Any]]]] - cooldown: NotRequired[CooldownMapping[Context[Any]]] - max_concurrency: NotRequired[MaxConcurrency] - require_var_positional: NotRequired[bool] - cooldown_after_parsing: NotRequired[bool] - ignore_extra: NotRequired[bool] - extras: NotRequired[Dict[Any, Any]] - - class _CommandKwargs(_CommandDecoratorKwargs): - name: NotRequired[str] - - class _GroupDecoratorKwargs(_CommandDecoratorKwargs): - invoke_without_command: NotRequired[bool] - case_insensitive: NotRequired[bool] - - class _GroupKwargs(_GroupDecoratorKwargs): - name: NotRequired[str] + class _CommandDecoratorKwargs(TypedDict, total=False): + enabled: bool + help: str + brief: str + usage: str + rest_is_raw: bool + aliases: List[str] + description: str + hidden: bool + checks: List[UserCheck[Context[Any]]] + cooldown: CooldownMapping[Context[Any]] + max_concurrency: MaxConcurrency + require_var_positional: bool + cooldown_after_parsing: bool + ignore_extra: bool + extras: Dict[Any, Any] + + class _CommandKwargs(_CommandDecoratorKwargs, total=False): + name: str + + class _GroupDecoratorKwargs(_CommandDecoratorKwargs, total=False): + invoke_without_command: bool + case_insensitive: bool + + class _GroupKwargs(_GroupDecoratorKwargs, total=False): + name: str __all__ = ( diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index 06b497234..90b44d16a 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -51,7 +51,7 @@ from .core import Group, Command, get_signature_parameters from .errors import CommandError if TYPE_CHECKING: - from typing_extensions import Self, Unpack, NotRequired + from typing_extensions import Self, Unpack import discord.abc @@ -67,28 +67,28 @@ if TYPE_CHECKING: _Bot, ) - class _HelpCommandOptions(TypedDict): - show_hidden: NotRequired[bool] - verify_checks: NotRequired[bool] - command_attrs: NotRequired[_CommandKwargs] - - class _BaseHelpCommandOptions(_HelpCommandOptions): - sort_commands: NotRequired[bool] - dm_help: NotRequired[bool] - dm_help_threshold: NotRequired[int] - no_category: NotRequired[str] - paginator: NotRequired[Paginator] - commands_heading: NotRequired[str] - - class _DefaultHelpCommandOptions(_BaseHelpCommandOptions): - width: NotRequired[int] - indent: NotRequired[int] - arguments_heading: NotRequired[str] - default_argument_description: NotRequired[str] - show_parameter_descriptions: NotRequired[bool] - - class _MinimalHelpCommandOptions(_BaseHelpCommandOptions): - aliases_heading: NotRequired[str] + class _HelpCommandOptions(TypedDict, total=False): + show_hidden: bool + verify_checks: bool + command_attrs: _CommandKwargs + + class _BaseHelpCommandOptions(_HelpCommandOptions, total=False): + sort_commands: bool + dm_help: bool + dm_help_threshold: int + no_category: str + paginator: Paginator + commands_heading: str + + class _DefaultHelpCommandOptions(_BaseHelpCommandOptions, total=False): + width: int + indent: int + arguments_heading: str + default_argument_description: str + show_parameter_descriptions: bool + + class _MinimalHelpCommandOptions(_BaseHelpCommandOptions, total=False): + aliases_heading: str __all__ = ( diff --git a/discord/ext/commands/hybrid.py b/discord/ext/commands/hybrid.py index 6e6ba6702..78e2f43bb 100644 --- a/discord/ext/commands/hybrid.py +++ b/discord/ext/commands/hybrid.py @@ -39,7 +39,7 @@ from .cog import Cog from .view import StringView if TYPE_CHECKING: - from typing_extensions import Self, ParamSpec, Concatenate, Unpack, NotRequired + from typing_extensions import Self, ParamSpec, Concatenate, Unpack from ._types import ContextT, Coro, BotT from .bot import Bot from .context import Context @@ -50,29 +50,27 @@ if TYPE_CHECKING: ) from .core import _CommandKwargs - class _HybridCommandKwargs( - _CommandKwargs, - ): - guild_ids: NotRequired[Optional[List[int]]] - guild_only: NotRequired[bool] - default_permissions: NotRequired[Optional[bool]] - nsfw: NotRequired[bool] - with_app_command: NotRequired[bool] - - class _HybridCommandDecoratorKwargs(_HybridCommandKwargs): - description: NotRequired[Union[str, app_commands.locale_str]] - - class _HybridGroupKwargs(_HybridCommandDecoratorKwargs): - with_app_command: NotRequired[bool] - guild_ids: NotRequired[Optional[List[int]]] - guild_only: NotRequired[bool] - default_permissions: NotRequired[Optional[bool]] - nsfw: NotRequired[bool] - description: NotRequired[str] - - class _HybridGroupDecoratorKwargs(_HybridGroupKwargs): - description: NotRequired[Union[str, app_commands.locale_str]] - fallback: NotRequired[Union[str, app_commands.locale_str]] + class _HybridCommandKwargs(_CommandKwargs, total=False): + guild_ids: list[int] + guild_only: bool + default_permissions: bool + nsfw: bool + with_app_command: bool + + class _HybridCommandDecoratorKwargs(_HybridCommandKwargs, total=False): + description: Union[str, app_commands.locale_str] + + class _HybridGroupKwargs(_HybridCommandDecoratorKwargs, total=False): + with_app_command: bool + guild_ids: list[int] + guild_only: bool + default_permissions: bool + nsfw: bool + description: str + + class _HybridGroupDecoratorKwargs(_HybridGroupKwargs, total=False): + description: Union[str, app_commands.locale_str] + fallback: Union[str, app_commands.locale_str] __all__ = ( diff --git a/discord/flags.py b/discord/flags.py index f3c57ba29..82a430482 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -46,42 +46,42 @@ from typing import ( from .enums import UserFlags if TYPE_CHECKING: - from typing_extensions import Self, Unpack, NotRequired - - class _IntentsFlagsKwargs(TypedDict): - guilds: NotRequired[bool] - members: NotRequired[bool] - moderation: NotRequired[bool] - bans: NotRequired[bool] - emojis: NotRequired[bool] - emojis_and_stickers: NotRequired[bool] - expressions: NotRequired[bool] - integrations: NotRequired[bool] - webhooks: NotRequired[bool] - invites: NotRequired[bool] - voice_states: NotRequired[bool] - presences: NotRequired[bool] - messages: NotRequired[bool] - guild_messages: NotRequired[bool] - dm_messages: NotRequired[bool] - reactions: NotRequired[bool] - guild_reactions: NotRequired[bool] - dm_reactions: NotRequired[bool] - typing: NotRequired[bool] - guild_typing: NotRequired[bool] - dm_typing: NotRequired[bool] - message_content: NotRequired[bool] - guild_scheduled_events: NotRequired[bool] - auto_moderation: NotRequired[bool] - auto_moderation_configuration: NotRequired[bool] - auto_moderation_execution: NotRequired[bool] - polls: NotRequired[bool] - guild_polls: NotRequired[bool] - dm_polls: NotRequired[bool] - - class _MemberCacheFlagsKwargs(TypedDict): - voice: NotRequired[bool] - joined: NotRequired[bool] + from typing_extensions import Self, Unpack + + class _IntentsFlagsKwargs(TypedDict, total=False): + guilds: bool + members: bool + moderation: bool + bans: bool + emojis: bool + emojis_and_stickers: bool + expressions: bool + integrations: bool + webhooks: bool + invites: bool + voice_states: bool + presences: bool + messages: bool + guild_messages: bool + dm_messages: bool + reactions: bool + guild_reactions: bool + dm_reactions: bool + typing: bool + guild_typing: bool + dm_typing: bool + message_content: bool + guild_scheduled_events: bool + auto_moderation: bool + auto_moderation_configuration: bool + auto_moderation_execution: bool + polls: bool + guild_polls: bool + dm_polls: bool + + class _MemberCacheFlagsKwargs(TypedDict, total=False): + voice: bool + joined: bool __all__ = ( diff --git a/discord/permissions.py b/discord/permissions.py index 0619dac03..e46f26805 100644 --- a/discord/permissions.py +++ b/discord/permissions.py @@ -33,121 +33,121 @@ __all__ = ( ) if TYPE_CHECKING: - from typing_extensions import Self, Unpack, NotRequired - - class _PermissionsKwargs(TypedDict): - create_instant_invite: NotRequired[bool] - kick_members: NotRequired[bool] - ban_members: NotRequired[bool] - administrator: NotRequired[bool] - manage_channels: NotRequired[bool] - manage_guild: NotRequired[bool] - add_reactions: NotRequired[bool] - view_audit_log: NotRequired[bool] - priority_speaker: NotRequired[bool] - stream: NotRequired[bool] - read_messages: NotRequired[bool] - view_channel: NotRequired[bool] - send_messages: NotRequired[bool] - send_tts_messages: NotRequired[bool] - manage_messages: NotRequired[bool] - embed_links: NotRequired[bool] - attach_files: NotRequired[bool] - read_message_history: NotRequired[bool] - mention_everyone: NotRequired[bool] - external_emojis: NotRequired[bool] - use_external_emojis: NotRequired[bool] - view_guild_insights: NotRequired[bool] - connect: NotRequired[bool] - speak: NotRequired[bool] - mute_members: NotRequired[bool] - deafen_members: NotRequired[bool] - move_members: NotRequired[bool] - use_voice_activation: NotRequired[bool] - change_nickname: NotRequired[bool] - manage_nicknames: NotRequired[bool] - manage_roles: NotRequired[bool] - manage_permissions: NotRequired[bool] - manage_webhooks: NotRequired[bool] - manage_expressions: NotRequired[bool] - manage_emojis: NotRequired[bool] - manage_emojis_and_stickers: NotRequired[bool] - use_application_commands: NotRequired[bool] - request_to_speak: NotRequired[bool] - manage_events: NotRequired[bool] - manage_threads: NotRequired[bool] - create_public_threads: NotRequired[bool] - create_private_threads: NotRequired[bool] - send_messages_in_threads: NotRequired[bool] - external_stickers: NotRequired[bool] - use_external_stickers: NotRequired[bool] - use_embedded_activities: NotRequired[bool] - moderate_members: NotRequired[bool] - use_soundboard: NotRequired[bool] - use_external_sounds: NotRequired[bool] - send_voice_messages: NotRequired[bool] - create_expressions: NotRequired[bool] - create_events: NotRequired[bool] - send_polls: NotRequired[bool] - create_polls: NotRequired[bool] - use_external_apps: NotRequired[bool] - - class _PermissionOverwriteKwargs(_PermissionsKwargs): - create_instant_invite: NotRequired[Optional[bool]] - kick_members: NotRequired[Optional[bool]] - ban_members: NotRequired[Optional[bool]] - administrator: NotRequired[Optional[bool]] - manage_channels: NotRequired[Optional[bool]] - manage_guild: NotRequired[Optional[bool]] - add_reactions: NotRequired[Optional[bool]] - view_audit_log: NotRequired[Optional[bool]] - priority_speaker: NotRequired[Optional[bool]] - stream: NotRequired[Optional[bool]] - read_messages: NotRequired[Optional[bool]] - view_channel: NotRequired[Optional[bool]] - send_messages: NotRequired[Optional[bool]] - send_tts_messages: NotRequired[Optional[bool]] - manage_messages: NotRequired[Optional[bool]] - embed_links: NotRequired[Optional[bool]] - attach_files: NotRequired[Optional[bool]] - read_message_history: NotRequired[Optional[bool]] - mention_everyone: NotRequired[Optional[bool]] - external_emojis: NotRequired[Optional[bool]] - use_external_emojis: NotRequired[Optional[bool]] - view_guild_insights: NotRequired[Optional[bool]] - connect: NotRequired[Optional[bool]] - speak: NotRequired[Optional[bool]] - mute_members: NotRequired[Optional[bool]] - deafen_members: NotRequired[Optional[bool]] - move_members: NotRequired[Optional[bool]] - use_voice_activation: NotRequired[Optional[bool]] - change_nickname: NotRequired[Optional[bool]] - manage_nicknames: NotRequired[Optional[bool]] - manage_roles: NotRequired[Optional[bool]] - manage_permissions: NotRequired[Optional[bool]] - manage_webhooks: NotRequired[Optional[bool]] - manage_expressions: NotRequired[Optional[bool]] - manage_emojis: NotRequired[Optional[bool]] - manage_emojis_and_stickers: NotRequired[Optional[bool]] - use_application_commands: NotRequired[Optional[bool]] - request_to_speak: NotRequired[Optional[bool]] - manage_events: NotRequired[Optional[bool]] - manage_threads: NotRequired[Optional[bool]] - create_public_threads: NotRequired[Optional[bool]] - create_private_threads: NotRequired[Optional[bool]] - send_messages_in_threads: NotRequired[Optional[bool]] - external_stickers: NotRequired[Optional[bool]] - use_external_stickers: NotRequired[Optional[bool]] - use_embedded_activities: NotRequired[Optional[bool]] - moderate_members: NotRequired[Optional[bool]] - use_soundboard: NotRequired[Optional[bool]] - use_external_sounds: NotRequired[Optional[bool]] - send_voice_messages: NotRequired[Optional[bool]] - create_expressions: NotRequired[Optional[bool]] - create_events: NotRequired[Optional[bool]] - send_polls: NotRequired[Optional[bool]] - create_polls: NotRequired[Optional[bool]] - use_external_apps: NotRequired[Optional[bool]] + from typing_extensions import Self, Unpack + + class _PermissionsKwargs(TypedDict, total=False): + create_instant_invite: bool + kick_members: bool + ban_members: bool + administrator: bool + manage_channels: bool + manage_guild: bool + add_reactions: bool + view_audit_log: bool + priority_speaker: bool + stream: bool + read_messages: bool + view_channel: bool + send_messages: bool + send_tts_messages: bool + manage_messages: bool + embed_links: bool + attach_files: bool + read_message_history: bool + mention_everyone: bool + external_emojis: bool + use_external_emojis: bool + view_guild_insights: bool + connect: bool + speak: bool + mute_members: bool + deafen_members: bool + move_members: bool + use_voice_activation: bool + change_nickname: bool + manage_nicknames: bool + manage_roles: bool + manage_permissions: bool + manage_webhooks: bool + manage_expressions: bool + manage_emojis: bool + manage_emojis_and_stickers: bool + use_application_commands: bool + request_to_speak: bool + manage_events: bool + manage_threads: bool + create_public_threads: bool + create_private_threads: bool + send_messages_in_threads: bool + external_stickers: bool + use_external_stickers: bool + use_embedded_activities: bool + moderate_members: bool + use_soundboard: bool + use_external_sounds: bool + send_voice_messages: bool + create_expressions: bool + create_events: bool + send_polls: bool + create_polls: bool + use_external_apps: bool + + class _PermissionOverwriteKwargs(_PermissionsKwargs, total=False): + create_instant_invite: Optional[bool] + kick_members: Optional[bool] + ban_members: Optional[bool] + administrator: Optional[bool] + manage_channels: Optional[bool] + manage_guild: Optional[bool] + add_reactions: Optional[bool] + view_audit_log: Optional[bool] + priority_speaker: Optional[bool] + stream: Optional[bool] + read_messages: Optional[bool] + view_channel: Optional[bool] + send_messages: Optional[bool] + send_tts_messages: Optional[bool] + manage_messages: Optional[bool] + embed_links: Optional[bool] + attach_files: Optional[bool] + read_message_history: Optional[bool] + mention_everyone: Optional[bool] + external_emojis: Optional[bool] + use_external_emojis: Optional[bool] + view_guild_insights: Optional[bool] + connect: Optional[bool] + speak: Optional[bool] + mute_members: Optional[bool] + deafen_members: Optional[bool] + move_members: Optional[bool] + use_voice_activation: Optional[bool] + change_nickname: Optional[bool] + manage_nicknames: Optional[bool] + manage_roles: Optional[bool] + manage_permissions: Optional[bool] + manage_webhooks: Optional[bool] + manage_expressions: Optional[bool] + manage_emojis: Optional[bool] + manage_emojis_and_stickers: Optional[bool] + use_application_commands: Optional[bool] + request_to_speak: Optional[bool] + manage_events: Optional[bool] + manage_threads: Optional[bool] + create_public_threads: Optional[bool] + create_private_threads: Optional[bool] + send_messages_in_threads: Optional[bool] + external_stickers: Optional[bool] + use_external_stickers: Optional[bool] + use_embedded_activities: Optional[bool] + moderate_members: Optional[bool] + use_soundboard: Optional[bool] + use_external_sounds: Optional[bool] + send_voice_messages: Optional[bool] + create_expressions: Optional[bool] + create_events: Optional[bool] + send_polls: Optional[bool] + create_polls: Optional[bool] + use_external_apps: Optional[bool] # A permission alias works like a regular flag but is marked diff --git a/discord/shard.py b/discord/shard.py index ecca84997..3725324d4 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -47,16 +47,16 @@ from .enums import Status from typing import TYPE_CHECKING, Any, Callable, Tuple, Type, Optional, List, Dict if TYPE_CHECKING: - from typing_extensions import Unpack, NotRequired + from typing_extensions import Unpack from .gateway import DiscordWebSocket from .activity import BaseActivity from .flags import Intents from .types.gateway import SessionStartLimit from .client import _ClientOptions - class _AutoShardedClientOptions(_ClientOptions): - shard_ids: NotRequired[Optional[List[int]]] - shard_connect_timeout: NotRequired[Optional[float]] + class _AutoShardedClientOptions(_ClientOptions, total=False): + shard_ids: List[int] + shard_connect_timeout: Optional[float] __all__ = (