diff --git a/disnake/abc.py b/disnake/abc.py index 245a6ff10d..f700da0c3e 100644 --- a/disnake/abc.py +++ b/disnake/abc.py @@ -28,9 +28,6 @@ from .enums import ( ChannelType, PartyType, - ThreadLayout, - ThreadSortOrder, - VideoQualityMode, try_enum_to_int, ) from .errors import ClientException @@ -42,7 +39,6 @@ from .partial_emoji import PartialEmoji from .permissions import PermissionOverwrite, Permissions from .role import Role -from .sticker import GuildSticker, StandardSticker, StickerItem from .utils import _overload_with_permissions from .voice_client import VoiceClient, VoiceProtocol @@ -67,7 +63,12 @@ from .client import Client from .embeds import Embed from .emoji import Emoji - from .enums import InviteTarget + from .enums import ( + InviteTarget, + ThreadLayout, + ThreadSortOrder, + VideoQualityMode, + ) from .guild import Guild, GuildChannel as AnyGuildChannel, GuildMessageable from .guild_scheduled_event import GuildScheduledEvent from .iterators import ChannelPinsIterator, HistoryIterator @@ -75,6 +76,7 @@ from .message import Message, MessageReference, PartialMessage from .poll import Poll from .state import ConnectionState + from .sticker import GuildSticker, StandardSticker, StickerItem from .threads import AnyThreadArchiveDuration, ForumTag from .types.channel import ( Channel as ChannelPayload, diff --git a/disnake/app_commands.py b/disnake/app_commands.py index ae4f323c63..1890de977c 100644 --- a/disnake/app_commands.py +++ b/disnake/app_commands.py @@ -11,7 +11,6 @@ ApplicationCommandPermissionType, ApplicationCommandType, ChannelType, - Locale, OptionType, enum_if_int, try_enum, @@ -25,6 +24,9 @@ if TYPE_CHECKING: from typing_extensions import Self + from .enums import ( + Locale, + ) from .i18n import LocalizationProtocol, LocalizationValue, LocalizedOptional, LocalizedRequired from .state import ConnectionState from .types.interactions import ( diff --git a/disnake/appinfo.py b/disnake/appinfo.py index c3cb60b3dc..c3949ca1c3 100644 --- a/disnake/appinfo.py +++ b/disnake/appinfo.py @@ -5,13 +5,14 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, cast from . import utils -from .asset import Asset, AssetBytes +from .asset import Asset from .enums import ApplicationEventWebhookStatus, try_enum from .flags import ApplicationFlags from .permissions import Permissions from .utils import MISSING if TYPE_CHECKING: + from .asset import AssetBytes from .guild import Guild from .state import ConnectionState from .types.appinfo import ( diff --git a/disnake/application_role_connection.py b/disnake/application_role_connection.py index df76bb9dd5..d5756df68e 100644 --- a/disnake/application_role_connection.py +++ b/disnake/application_role_connection.py @@ -5,12 +5,12 @@ from typing import TYPE_CHECKING from .enums import ApplicationRoleConnectionMetadataType, enum_if_int, try_enum -from .i18n import LocalizationValue, Localized +from .i18n import Localized if TYPE_CHECKING: from typing_extensions import Self - from .i18n import LocalizationProtocol, LocalizedRequired + from .i18n import LocalizationProtocol, LocalizationValue, LocalizedRequired from .types.application_role_connection import ( ApplicationRoleConnectionMetadata as ApplicationRoleConnectionMetadataPayload, ) diff --git a/disnake/audit_logs.py b/disnake/audit_logs.py index cd3384bbc9..5f7d2fe006 100644 --- a/disnake/audit_logs.py +++ b/disnake/audit_logs.py @@ -19,15 +19,14 @@ cast, ) -from . import abc, enums, flags, utils +from . import enums, flags, utils from .app_commands import ApplicationCommandPermissions from .asset import Asset -from .automod import AutoModAction, AutoModTriggerMetadata, _automod_action_factory +from .automod import AutoModTriggerMetadata, _automod_action_factory from .colour import Colour from .invite import Invite from .mixins import Hashable from .object import Object -from .partial_emoji import PartialEmoji from .permissions import PermissionOverwrite, Permissions from .threads import ForumTag, Thread @@ -41,13 +40,15 @@ if TYPE_CHECKING: import datetime + from . import abc from .app_commands import APIApplicationCommand - from .automod import AutoModRule + from .automod import AutoModAction, AutoModRule from .emoji import Emoji from .guild import Guild from .guild_scheduled_event import GuildScheduledEvent from .integrations import PartialIntegration from .member import Member + from .partial_emoji import PartialEmoji from .role import Role from .stage_instance import StageInstance from .sticker import GuildSticker diff --git a/disnake/channel.py b/disnake/channel.py index 99c5ee3d89..c5b8c66ed6 100644 --- a/disnake/channel.py +++ b/disnake/channel.py @@ -3,7 +3,6 @@ from __future__ import annotations import asyncio -import datetime import time from typing import ( TYPE_CHECKING, @@ -41,13 +40,13 @@ ) from .errors import ClientException from .file import File -from .flags import ChannelFlags, MessageFlags +from .flags import ChannelFlags from .iterators import ArchivedThreadIterator from .mixins import Hashable from .object import Object from .partial_emoji import PartialEmoji -from .permissions import PermissionOverwrite, Permissions -from .soundboard import GuildSoundboardSound, PartialSoundboardSound, SoundboardSound +from .permissions import Permissions +from .soundboard import GuildSoundboardSound, PartialSoundboardSound from .stage_instance import StageInstance from .threads import ForumTag, Thread from .utils import MISSING @@ -68,16 +67,21 @@ ) if TYPE_CHECKING: + import datetime + from typing_extensions import Never, Self from .abc import Snowflake, SnowflakeTime from .asset import AssetBytes from .embeds import Embed from .emoji import Emoji + from .flags import MessageFlags from .guild import Guild, GuildChannel as GuildChannelType from .member import Member, VoiceState from .message import AllowedMentions, Message, PartialMessage + from .permissions import PermissionOverwrite from .role import Role + from .soundboard import SoundboardSound from .state import ConnectionState from .sticker import GuildSticker, StandardSticker, StickerItem from .threads import AnyThreadArchiveDuration, ThreadType diff --git a/disnake/client.py b/disnake/client.py index 653d2c0bbb..848a077ce6 100644 --- a/disnake/client.py +++ b/disnake/client.py @@ -8,7 +8,7 @@ import sys import traceback import types -from datetime import datetime, timedelta +from datetime import timedelta from errno import ECONNRESET from typing import ( TYPE_CHECKING, @@ -33,13 +33,11 @@ import aiohttp from . import abc, utils -from .activity import ActivityTypes, BaseActivity, create_activity +from .activity import BaseActivity, create_activity from .app_commands import ( APIMessageCommand, APISlashCommand, APIUserCommand, - ApplicationCommand, - GuildApplicationCommandPermissions, ) from .appinfo import AppInfo from .application_role_connection import ApplicationRoleConnectionMetadata @@ -47,7 +45,7 @@ from .channel import PartialMessageable, _threaded_channel_factory from .emoji import Emoji from .entitlement import Entitlement -from .enums import ApplicationCommandType, ChannelType, Event, Status +from .enums import ChannelType, Event, Status from .errors import ( ConnectionClosed, GatewayNotFound, @@ -56,23 +54,21 @@ PrivilegedIntentsRequired, SessionStartLimitReached, ) -from .flags import ApplicationFlags, Intents, MemberCacheFlags from .gateway import DiscordWebSocket, ReconnectWebSocket from .guild import Guild, GuildBuilder from .guild_preview import GuildPreview from .http import HTTPClient -from .i18n import LocalizationProtocol, LocalizationStore +from .i18n import LocalizationStore from .invite import Invite from .iterators import EntitlementIterator, GuildIterator from .mentions import AllowedMentions from .object import Object from .sku import SKU -from .soundboard import GuildSoundboardSound, SoundboardSound +from .soundboard import SoundboardSound from .stage_instance import StageInstance from .state import ConnectionState -from .sticker import GuildSticker, StandardSticker, StickerPack, _sticker_factory +from .sticker import StickerPack, _sticker_factory from .template import Template -from .threads import Thread from .ui.view import View from .user import ClientUser, User from .utils import MISSING, deprecated @@ -82,14 +78,30 @@ from .widget import Widget if TYPE_CHECKING: + from datetime import datetime + from typing_extensions import NotRequired from .abc import GuildChannel, PrivateChannel, Snowflake, SnowflakeTime - from .app_commands import APIApplicationCommand, MessageCommand, SlashCommand, UserCommand + from .activity import ActivityTypes + from .app_commands import ( + APIApplicationCommand, + ApplicationCommand, + GuildApplicationCommandPermissions, + MessageCommand, + SlashCommand, + UserCommand, + ) from .asset import AssetBytes from .channel import DMChannel + from .enums import ApplicationCommandType + from .flags import ApplicationFlags, Intents, MemberCacheFlags + from .i18n import LocalizationProtocol from .member import Member from .message import Message + from .soundboard import GuildSoundboardSound + from .sticker import GuildSticker, StandardSticker + from .threads import Thread from .types.application_role_connection import ( ApplicationRoleConnectionMetadata as ApplicationRoleConnectionMetadataPayload, ) diff --git a/disnake/embeds.py b/disnake/embeds.py index eb91c25bfb..d1c6870aa1 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -21,7 +21,6 @@ from . import utils from .colour import Colour -from .file import File from .utils import MISSING, classproperty, warn_deprecated __all__ = ("Embed",) @@ -75,6 +74,8 @@ def __eq__(self, other: Any) -> bool: EmbedVideo as EmbedVideoPayload, ) + from .file import File + class _EmbedFooterProxy(Sized, Protocol): text: Optional[str] icon_url: Optional[str] diff --git a/disnake/entitlement.py b/disnake/entitlement.py index e46adf42ba..c8f2843f28 100644 --- a/disnake/entitlement.py +++ b/disnake/entitlement.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, Optional from .enums import EntitlementType, try_enum @@ -10,6 +9,8 @@ from .utils import _get_as_snowflake, parse_time, snowflake_time, utcnow if TYPE_CHECKING: + import datetime + from .guild import Guild from .state import ConnectionState from .types.entitlement import Entitlement as EntitlementPayload diff --git a/disnake/ext/commands/base_core.py b/disnake/ext/commands/base_core.py index fdd543df51..2fec8c13bc 100644 --- a/disnake/ext/commands/base_core.py +++ b/disnake/ext/commands/base_core.py @@ -20,7 +20,6 @@ overload, ) -from disnake.app_commands import ApplicationCommand from disnake.enums import ApplicationCommandType from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.permissions import Permissions @@ -32,16 +31,18 @@ maybe_coroutine, ) -from .cooldowns import BucketType, CooldownMapping, MaxConcurrency +from .cooldowns import BucketType, CooldownMapping from .errors import CheckFailure, CommandError, CommandInvokeError, CommandOnCooldown if TYPE_CHECKING: from typing_extensions import Concatenate, ParamSpec, Self + from disnake.app_commands import ApplicationCommand from disnake.interactions import ApplicationCommandInteraction from ._types import AppCheck, Coro, Error, Hook from .cog import Cog + from .cooldowns import MaxConcurrency from .interaction_bot_base import InteractionBotBase ApplicationCommandInteractionT = TypeVar( diff --git a/disnake/ext/commands/context.py b/disnake/ext/commands/context.py index 86112b6781..0387390d99 100644 --- a/disnake/ext/commands/context.py +++ b/disnake/ext/commands/context.py @@ -2,7 +2,6 @@ from __future__ import annotations -import inspect import re from typing import TYPE_CHECKING, Any, Dict, Generic, List, Optional, TypeVar, Union @@ -12,6 +11,8 @@ from disnake.message import Message if TYPE_CHECKING: + import inspect + from typing_extensions import ParamSpec from disnake.channel import DMChannel, GroupChannel diff --git a/disnake/ext/commands/converter.py b/disnake/ext/commands/converter.py index e26c526a15..12d030c823 100644 --- a/disnake/ext/commands/converter.py +++ b/disnake/ext/commands/converter.py @@ -25,7 +25,7 @@ import disnake -from .context import AnyContext, Context +from .context import Context from .errors import ( BadArgument, BadBoolArgument, @@ -55,6 +55,8 @@ if TYPE_CHECKING: from disnake.abc import MessageableChannel + from .context import AnyContext + # TODO: USE ACTUAL FUNCTIONS INSTEAD OF USELESS CLASSES diff --git a/disnake/ext/commands/core.py b/disnake/ext/commands/core.py index e2defd9197..58a97137e8 100644 --- a/disnake/ext/commands/core.py +++ b/disnake/ext/commands/core.py @@ -37,7 +37,7 @@ from ._types import _BaseCommand from .cog import Cog -from .context import AnyContext, Context +from .context import Context from .converter import Greedy, get_converter, run_converters from .cooldowns import BucketType, Cooldown, CooldownMapping, DynamicCooldownMapping, MaxConcurrency from .errors import ( @@ -69,6 +69,7 @@ from disnake.message import Message from ._types import AppCheck, Check, Coro, CoroFunc, Error, Hook + from .context import AnyContext __all__ = ( diff --git a/disnake/ext/commands/ctx_menus_core.py b/disnake/ext/commands/ctx_menus_core.py index 03e3be1262..79161fd505 100644 --- a/disnake/ext/commands/ctx_menus_core.py +++ b/disnake/ext/commands/ctx_menus_core.py @@ -5,26 +5,26 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Sequence, Tuple, Union from disnake.app_commands import MessageCommand, UserCommand -from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.i18n import Localized -from disnake.permissions import Permissions from disnake.utils import iscoroutinefunction from .base_core import InvokableApplicationCommand, _get_overridden_method -from .errors import CommandError from .params import safe_call if TYPE_CHECKING: from typing_extensions import ParamSpec + from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.i18n import LocalizedOptional from disnake.interactions import ( ApplicationCommandInteraction, MessageCommandInteraction, UserCommandInteraction, ) + from disnake.permissions import Permissions from .base_core import CogT, InteractionCommandCallback + from .errors import CommandError P = ParamSpec("P") diff --git a/disnake/ext/commands/help.py b/disnake/ext/commands/help.py index 876c7478da..6be72eff67 100644 --- a/disnake/ext/commands/help.py +++ b/disnake/ext/commands/help.py @@ -26,7 +26,6 @@ import disnake.abc import disnake.utils -from .context import BotT, Context from .core import Command, Group from .errors import CommandError @@ -37,6 +36,7 @@ from .bot import AutoShardedBot, Bot from .bot_base import BotBase from .cog import Cog + from .context import BotT, Context # note: no InteractionBot AnyBot = Union[Bot, AutoShardedBot] diff --git a/disnake/ext/commands/interaction_bot_base.py b/disnake/ext/commands/interaction_bot_base.py index 6d9f57cbbf..13b51eb85c 100644 --- a/disnake/ext/commands/interaction_bot_base.py +++ b/disnake/ext/commands/interaction_bot_base.py @@ -25,14 +25,11 @@ ) import disnake -from disnake.app_commands import ApplicationCommand, Option from disnake.custom_warnings import SyncWarning from disnake.enums import ApplicationCommandType -from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.utils import iscoroutinefunction, warn_deprecated from . import errors -from .base_core import InvokableApplicationCommand from .common_bot_base import CommonBotBase from .ctx_menus_core import ( InvokableMessageCommand, @@ -42,11 +39,13 @@ ) from .errors import CommandRegistrationError from .flags import CommandSyncFlags -from .slash_core import InvokableSlashCommand, SubCommand, SubCommandGroup, slash_command +from .slash_core import InvokableSlashCommand, SubCommandGroup, slash_command if TYPE_CHECKING: from typing_extensions import NotRequired, ParamSpec + from disnake.app_commands import ApplicationCommand, Option + from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.i18n import LocalizedOptional from disnake.interactions import ( ApplicationCommandInteraction, @@ -56,7 +55,13 @@ from disnake.permissions import Permissions from ._types import AppCheck, CoroFunc - from .base_core import CogT, CommandCallback, InteractionCommandCallback + from .base_core import ( + CogT, + CommandCallback, + InteractionCommandCallback, + InvokableApplicationCommand, + ) + from .slash_core import SubCommand P = ParamSpec("P") diff --git a/disnake/ext/commands/params.py b/disnake/ext/commands/params.py index 51d9a31f64..f147f615f4 100644 --- a/disnake/ext/commands/params.py +++ b/disnake/ext/commands/params.py @@ -40,7 +40,7 @@ import disnake from disnake.app_commands import Option, OptionChoice from disnake.channel import _channel_type_factory -from disnake.enums import ChannelType, OptionType, try_enum_to_int +from disnake.enums import OptionType, try_enum_to_int from disnake.ext import commands from disnake.i18n import Localized from disnake.interactions import ApplicationCommandInteraction @@ -60,6 +60,7 @@ from typing_extensions import Concatenate, ParamSpec, Self, TypeGuard from disnake.app_commands import Choices + from disnake.enums import ChannelType from disnake.i18n import LocalizationValue, LocalizedOptional from disnake.types.interactions import ApplicationCommandOptionChoiceValue diff --git a/disnake/ext/commands/slash_core.py b/disnake/ext/commands/slash_core.py index 8a39a8b476..456c98d586 100644 --- a/disnake/ext/commands/slash_core.py +++ b/disnake/ext/commands/slash_core.py @@ -20,10 +20,7 @@ from disnake import utils from disnake.app_commands import Option, SlashCommand from disnake.enums import OptionType -from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.i18n import Localized -from disnake.interactions import ApplicationCommandInteraction -from disnake.permissions import Permissions from .base_core import InvokableApplicationCommand, _get_overridden_method from .errors import CommandError, CommandInvokeError @@ -31,7 +28,10 @@ if TYPE_CHECKING: from disnake.app_commands import Choices + from disnake.flags import ApplicationInstallTypes, InteractionContextTypes from disnake.i18n import LocalizedOptional + from disnake.interactions import ApplicationCommandInteraction + from disnake.permissions import Permissions from .base_core import CommandCallback diff --git a/disnake/guild.py b/disnake/guild.py index cabf40fe75..a2fc6711ea 100644 --- a/disnake/guild.py +++ b/disnake/guild.py @@ -25,7 +25,6 @@ ) from . import abc, utils -from .app_commands import GuildApplicationCommandPermissions from .asset import Asset from .automod import AutoModAction, AutoModRule from .bans import BanEntry, BulkBanResult @@ -42,8 +41,6 @@ from .colour import Colour from .emoji import Emoji from .enums import ( - AuditLogAction, - AutoModEventType, AutoModTriggerType, ChannelType, ContentFilter, @@ -52,19 +49,15 @@ Locale, NotificationLevel, NSFWLevel, - ThreadLayout, - ThreadSortOrder, VerificationLevel, - VideoQualityMode, WidgetStyle, try_enum, try_enum_to_int, ) from .errors import ClientException, HTTPException, InvalidData -from .file import File from .flags import SystemChannelFlags from .guild_scheduled_event import GuildScheduledEvent, GuildScheduledEventMetadata -from .integrations import Integration, _integration_factory +from .integrations import _integration_factory from .invite import Invite from .iterators import AuditLogIterator, BanIterator, MemberIterator from .member import Member, VoiceState @@ -94,9 +87,18 @@ if TYPE_CHECKING: from .abc import Snowflake, SnowflakeTime - from .app_commands import APIApplicationCommand + from .app_commands import APIApplicationCommand, GuildApplicationCommandPermissions from .asset import AssetBytes from .automod import AutoModTriggerMetadata + from .enums import ( + AuditLogAction, + AutoModEventType, + ThreadLayout, + ThreadSortOrder, + VideoQualityMode, + ) + from .file import File + from .integrations import Integration from .permissions import Permissions from .state import ConnectionState from .template import Template diff --git a/disnake/guild_scheduled_event.py b/disnake/guild_scheduled_event.py index 66c3181546..b0f85611e2 100644 --- a/disnake/guild_scheduled_event.py +++ b/disnake/guild_scheduled_event.py @@ -2,7 +2,6 @@ from __future__ import annotations -from datetime import datetime from typing import TYPE_CHECKING, Any, Dict, Literal, Optional, overload from .asset import Asset @@ -25,6 +24,8 @@ ) if TYPE_CHECKING: + from datetime import datetime + from .abc import GuildChannel, Snowflake from .asset import AssetBytes from .guild import Guild diff --git a/disnake/i18n.py b/disnake/i18n.py index 79de355d6d..5c396b780f 100644 --- a/disnake/i18n.py +++ b/disnake/i18n.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging -import os import warnings from abc import ABC, abstractmethod from collections import defaultdict @@ -29,6 +28,8 @@ from .errors import LocalizationKeyError if TYPE_CHECKING: + import os + from typing_extensions import Self LocalizedRequired = Union[str, "Localized[str]"] diff --git a/disnake/interactions/application_command.py b/disnake/interactions/application_command.py index 3f92637488..fe8b77b734 100644 --- a/disnake/interactions/application_command.py +++ b/disnake/interactions/application_command.py @@ -5,11 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple, Union from .. import utils -from ..enums import ApplicationCommandType, Locale, OptionType, try_enum -from ..guild import Guild -from ..member import Member -from ..message import Message -from ..user import User +from ..enums import ApplicationCommandType, OptionType, try_enum from .base import ClientT, Interaction, InteractionDataResolved __all__ = ( @@ -33,12 +29,17 @@ MISSING = utils.MISSING if TYPE_CHECKING: + from ..enums import Locale from ..ext.commands import InvokableApplicationCommand + from ..guild import Guild + from ..member import Member + from ..message import Message from ..state import ConnectionState from ..types.interactions import ( ApplicationCommandInteraction as ApplicationCommandInteractionPayload, ApplicationCommandInteractionData as ApplicationCommandInteractionDataPayload, ) + from ..user import User class ApplicationCommandInteraction(Interaction[ClientT]): diff --git a/disnake/interactions/base.py b/disnake/interactions/base.py index ddd6b779e9..bdfd9dfbcb 100644 --- a/disnake/interactions/base.py +++ b/disnake/interactions/base.py @@ -44,7 +44,6 @@ ) from ..flags import InteractionContextTypes, MessageFlags from ..guild import Guild -from ..http import HTTPClient from ..i18n import Localized from ..member import Member from ..message import Attachment, AuthorizingIntegrationOwners, Message @@ -52,7 +51,7 @@ from ..permissions import Permissions from ..role import Role from ..ui.action_row import normalize_components, normalize_components_to_dict -from ..user import ClientUser, User +from ..user import User from ..webhook.async_ import Webhook, async_context, handle_message_parameters __all__ = ( @@ -73,6 +72,7 @@ from ..embeds import Embed from ..ext.commands import AutoShardedBot, Bot from ..file import File + from ..http import HTTPClient from ..mentions import AllowedMentions from ..poll import Poll from ..state import ConnectionState @@ -90,6 +90,7 @@ from ..ui._types import MessageComponents, ModalComponents, ModalTopLevelComponent from ..ui.modal import Modal from ..ui.view import View + from ..user import ClientUser from .message import MessageInteraction from .modal import ModalInteraction diff --git a/disnake/interactions/message.py b/disnake/interactions/message.py index 0a984dac2c..9e51040eec 100644 --- a/disnake/interactions/message.py +++ b/disnake/interactions/message.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union -from ..components import VALID_ACTION_ROW_MESSAGE_COMPONENT_TYPES, ActionRowMessageComponent +from ..components import VALID_ACTION_ROW_MESSAGE_COMPONENT_TYPES from ..enums import ComponentType, try_enum from ..message import Message from ..ui.action_row import walk_components @@ -18,6 +18,7 @@ if TYPE_CHECKING: from ..abc import AnyChannel + from ..components import ActionRowMessageComponent from ..member import Member from ..role import Role from ..state import ConnectionState diff --git a/disnake/member.py b/disnake/member.py index aae354f268..72de67c163 100644 --- a/disnake/member.py +++ b/disnake/member.py @@ -25,8 +25,8 @@ import disnake.abc from . import utils -from .activity import ActivityTypes, create_activity -from .asset import Asset, AssetBytes +from .activity import create_activity +from .asset import Asset from .colour import Colour from .enums import Status, try_enum from .flags import MemberFlags @@ -44,6 +44,8 @@ from typing_extensions import Self from .abc import Snowflake + from .activity import ActivityTypes + from .asset import AssetBytes from .channel import DMChannel, StageChannel, VoiceChannel from .flags import PublicUserFlags from .guild import Guild diff --git a/disnake/message.py b/disnake/message.py index 62e5072e22..9bdddae6c1 100644 --- a/disnake/message.py +++ b/disnake/message.py @@ -3,11 +3,9 @@ from __future__ import annotations import asyncio -import datetime import io import re from base64 import b64decode, b64encode -from os import PathLike from typing import ( TYPE_CHECKING, Any, @@ -25,7 +23,7 @@ from . import utils from .channel import PartialMessageable -from .components import MessageTopLevelComponent, _message_component_factory +from .components import _message_component_factory from .embeds import Embed from .emoji import Emoji from .enums import ( @@ -47,14 +45,17 @@ from .reaction import Reaction from .sticker import StickerItem from .threads import Thread -from .user import User from .utils import MISSING, _get_as_snowflake, assert_never, deprecated, escape_mentions if TYPE_CHECKING: + import datetime + from os import PathLike + from typing_extensions import Self from .abc import GuildChannel, MessageableChannel, Snowflake from .channel import DMChannel, GroupChannel + from .components import MessageTopLevelComponent from .guild import GuildMessageable from .mentions import AllowedMentions from .role import Role @@ -88,6 +89,7 @@ from .types.user import User as UserPayload from .ui._types import MessageComponents from .ui.view import View + from .user import User EmojiInputType = Union[Emoji, PartialEmoji, str] diff --git a/disnake/player.py b/disnake/player.py index 1b7ec78b88..97b060f241 100644 --- a/disnake/player.py +++ b/disnake/player.py @@ -3,7 +3,6 @@ from __future__ import annotations import asyncio -import io import logging import re import shlex @@ -21,6 +20,8 @@ from .opus import Encoder as OpusEncoder if TYPE_CHECKING: + import io + from typing_extensions import Self from .voice_client import VoiceClient diff --git a/disnake/poll.py b/disnake/poll.py index bea0109987..da6037952a 100644 --- a/disnake/poll.py +++ b/disnake/poll.py @@ -6,8 +6,7 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Union from . import utils -from .abc import Snowflake -from .emoji import Emoji, _EmojiTag +from .emoji import _EmojiTag from .enums import PollLayoutType, try_enum from .iterators import PollAnswerIterator from .partial_emoji import PartialEmoji @@ -15,6 +14,8 @@ if TYPE_CHECKING: from datetime import datetime + from .abc import Snowflake + from .emoji import Emoji from .message import Message from .state import ConnectionState from .types.poll import ( diff --git a/disnake/shard.py b/disnake/shard.py index c85ad2312f..77fde2fc29 100644 --- a/disnake/shard.py +++ b/disnake/shard.py @@ -23,7 +23,7 @@ import aiohttp from .backoff import ExponentialBackoff -from .client import Client, GatewayParams, SessionStartLimit +from .client import Client, SessionStartLimit from .enums import Status from .errors import ( ClientException, @@ -40,6 +40,7 @@ from typing_extensions import Self from .activity import BaseActivity + from .client import GatewayParams from .flags import Intents, MemberCacheFlags from .i18n import LocalizationProtocol from .mentions import AllowedMentions diff --git a/disnake/sku.py b/disnake/sku.py index 6609500c26..a87d8a8e1f 100644 --- a/disnake/sku.py +++ b/disnake/sku.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, Optional from .enums import SKUType, try_enum @@ -13,6 +12,8 @@ from .utils import snowflake_time if TYPE_CHECKING: + import datetime + from .abc import Snowflake, SnowflakeTime from .state import ConnectionState from .types.sku import SKU as SKUPayload diff --git a/disnake/soundboard.py b/disnake/soundboard.py index 70fa659835..33e258e54f 100644 --- a/disnake/soundboard.py +++ b/disnake/soundboard.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, Any, Dict, Optional, Union from .asset import Asset, AssetMixin @@ -11,6 +10,8 @@ from .utils import MISSING, _get_as_snowflake, snowflake_time if TYPE_CHECKING: + import datetime + from .emoji import Emoji from .guild import Guild from .state import ConnectionState diff --git a/disnake/stage_instance.py b/disnake/stage_instance.py index e116b356a6..bd2ce4e20d 100644 --- a/disnake/stage_instance.py +++ b/disnake/stage_instance.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, Optional from .enums import StagePrivacyLevel, try_enum @@ -12,6 +11,8 @@ __all__ = ("StageInstance",) if TYPE_CHECKING: + import datetime + from .channel import StageChannel from .guild import Guild from .guild_scheduled_event import GuildScheduledEvent diff --git a/disnake/state.py b/disnake/state.py index 9922963a40..590fa22b7d 100644 --- a/disnake/state.py +++ b/disnake/state.py @@ -50,14 +50,13 @@ from .components import _SELECT_COMPONENT_TYPES from .emoji import Emoji from .entitlement import Entitlement -from .enums import ApplicationCommandType, ChannelType, ComponentType, MessageType, Status, try_enum +from .enums import ChannelType, ComponentType, MessageType, Status, try_enum from .flags import ApplicationFlags, Intents, MemberCacheFlags from .guild import Guild from .guild_scheduled_event import GuildScheduledEvent from .integrations import _integration_factory from .interactions import ( ApplicationCommandInteraction, - Interaction, MessageInteraction, ModalInteraction, ) @@ -90,8 +89,8 @@ from .sticker import GuildSticker from .subscription import Subscription from .threads import Thread, ThreadMember -from .ui.modal import Modal, ModalStore -from .ui.view import View, ViewStore +from .ui.modal import ModalStore +from .ui.view import ViewStore from .user import ClientUser, User from .utils import MISSING from .webhook import Webhook @@ -102,9 +101,13 @@ from .abc import AnyChannel, MessageableChannel, PrivateChannel from .app_commands import APIApplicationCommand, ApplicationCommand from .client import Client + from .enums import ApplicationCommandType from .gateway import DiscordWebSocket from .guild import GuildChannel, VocalGuildChannel from .http import HTTPClient + from .interactions import ( + Interaction, + ) from .types import gateway from .types.activity import Activity as ActivityPayload from .types.channel import DMChannel as DMChannelPayload @@ -116,6 +119,8 @@ from .types.sticker import GuildSticker as GuildStickerPayload from .types.user import User as UserPayload from .types.webhook import Webhook as WebhookPayload + from .ui.modal import Modal + from .ui.view import View from .voice_client import VoiceProtocol Channel = Union[GuildChannel, VocalGuildChannel, PrivateChannel] diff --git a/disnake/subscription.py b/disnake/subscription.py index 8bee0ebf76..68d19ef71e 100644 --- a/disnake/subscription.py +++ b/disnake/subscription.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, List, Optional from .enums import SubscriptionStatus, try_enum @@ -10,6 +9,8 @@ from .utils import parse_time, snowflake_time if TYPE_CHECKING: + import datetime + from .state import ConnectionState from .types.subscription import Subscription as SubscriptionPayload from .user import User diff --git a/disnake/team.py b/disnake/team.py index 9541358c12..5b67a1d26e 100644 --- a/disnake/team.py +++ b/disnake/team.py @@ -2,7 +2,6 @@ from __future__ import annotations -import datetime from typing import TYPE_CHECKING, List, Optional from . import utils @@ -11,6 +10,8 @@ from .user import BaseUser if TYPE_CHECKING: + import datetime + from .state import ConnectionState from .types.team import Team as TeamPayload, TeamMember as TeamMemberPayload diff --git a/disnake/template.py b/disnake/template.py index 921c4c8d96..5ccbb3d054 100644 --- a/disnake/template.py +++ b/disnake/template.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, List, NoReturn, Optional -from .guild import Guild, Member +from .guild import Guild from .utils import MISSING, _assetbytes_to_base64_data, parse_time __all__ = ("Template",) @@ -14,6 +14,7 @@ from .asset import AssetBytes from .flags import MemberCacheFlags + from .guild import Member from .state import ConnectionState from .types.emoji import Emoji as EmojiPayload from .types.template import Template as TemplatePayload diff --git a/disnake/threads.py b/disnake/threads.py index 0ff06073a8..6b9729be7b 100644 --- a/disnake/threads.py +++ b/disnake/threads.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Literal, Optional, Sequence, Union from .abc import GuildChannel, Messageable -from .enums import ChannelType, ThreadArchiveDuration, try_enum, try_enum_to_int +from .enums import ChannelType, try_enum, try_enum_to_int from .errors import ClientException from .flags import ChannelFlags from .mixins import Hashable @@ -30,6 +30,7 @@ from .abc import Snowflake, SnowflakeTime from .channel import CategoryChannel, ForumChannel, MediaChannel, TextChannel from .emoji import Emoji + from .enums import ThreadArchiveDuration from .guild import Guild from .member import Member from .message import Message, PartialMessage diff --git a/disnake/types/activity.py b/disnake/types/activity.py index 749f015bdc..5be915abc5 100644 --- a/disnake/types/activity.py +++ b/disnake/types/activity.py @@ -2,12 +2,13 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + from .user import User StatusType = Literal["idle", "dnd", "online", "offline"] StatusDisplayType = Literal[0, 1, 2] diff --git a/disnake/types/appinfo.py b/disnake/types/appinfo.py index 940462dfa3..d207c7ef29 100644 --- a/disnake/types/appinfo.py +++ b/disnake/types/appinfo.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import Dict, List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, Dict, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake -from .team import Team -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + from .team import Team + from .user import User # (also called "installation context", which seems more accurate) ApplicationIntegrationType = Literal[0, 1] # GUILD_INSTALL, USER_INSTALL diff --git a/disnake/types/application_role_connection.py b/disnake/types/application_role_connection.py index af89e45efb..279e8ad2b6 100644 --- a/disnake/types/application_role_connection.py +++ b/disnake/types/application_role_connection.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Literal, TypedDict +from typing import TYPE_CHECKING, Literal, TypedDict from typing_extensions import NotRequired -from .i18n import LocalizationDict +if TYPE_CHECKING: + from .i18n import LocalizationDict ApplicationRoleConnectionMetadataType = Literal[1, 2, 3, 4, 5, 6, 7, 8] diff --git a/disnake/types/audit_log.py b/disnake/types/audit_log.py index cad5b52f4e..ba5aadf7a9 100644 --- a/disnake/types/audit_log.py +++ b/disnake/types/audit_log.py @@ -2,33 +2,35 @@ from __future__ import annotations -import datetime -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired -from .automod import ( - AutoModAction, - AutoModEventType, - AutoModRule, - AutoModTriggerMetadata, - AutoModTriggerType, -) -from .channel import ChannelType, PermissionOverwrite, VideoQualityMode -from .guild import ( - DefaultMessageNotificationLevel, - ExplicitContentFilterLevel, - MFALevel, - VerificationLevel, -) -from .guild_scheduled_event import GuildScheduledEvent -from .integration import IntegrationExpireBehavior, PartialIntegration -from .interactions import ApplicationCommand, ApplicationCommandPermissions -from .role import Role -from .snowflake import Snowflake -from .threads import Thread -from .user import User -from .webhook import Webhook +if TYPE_CHECKING: + import datetime + + from .automod import ( + AutoModAction, + AutoModEventType, + AutoModRule, + AutoModTriggerMetadata, + AutoModTriggerType, + ) + from .channel import ChannelType, PermissionOverwrite, VideoQualityMode + from .guild import ( + DefaultMessageNotificationLevel, + ExplicitContentFilterLevel, + MFALevel, + VerificationLevel, + ) + from .guild_scheduled_event import GuildScheduledEvent + from .integration import IntegrationExpireBehavior, PartialIntegration + from .interactions import ApplicationCommand, ApplicationCommandPermissions + from .role import Role + from .snowflake import Snowflake + from .threads import Thread + from .user import User + from .webhook import Webhook AuditLogEvent = Literal[ 1, diff --git a/disnake/types/automod.py b/disnake/types/automod.py index f7ac372e5e..c8ff6af0c1 100644 --- a/disnake/types/automod.py +++ b/disnake/types/automod.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import List, Literal, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, TypedDict, Union from typing_extensions import NotRequired -from .snowflake import Snowflake, SnowflakeList +if TYPE_CHECKING: + from .snowflake import Snowflake, SnowflakeList AutoModTriggerType = Literal[1, 3, 4, 5] AutoModEventType = Literal[1] diff --git a/disnake/types/channel.py b/disnake/types/channel.py index d10a688caa..d342de10b0 100644 --- a/disnake/types/channel.py +++ b/disnake/types/channel.py @@ -1,13 +1,15 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired -from .message import MessagePin -from .snowflake import Snowflake -from .threads import ForumTag, ThreadArchiveDurationLiteral, ThreadMember, ThreadMetadata -from .user import PartialUser +if TYPE_CHECKING: + from .message import MessagePin + from .snowflake import Snowflake + from .threads import ForumTag, ThreadArchiveDurationLiteral, ThreadMember, ThreadMetadata + from .user import PartialUser OverwriteType = Literal[0, 1] diff --git a/disnake/types/components.py b/disnake/types/components.py index fa13f7d3be..2e6b94a5f8 100644 --- a/disnake/types/components.py +++ b/disnake/types/components.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired, Required, TypeAlias -from .channel import ChannelType -from .emoji import PartialEmoji -from .snowflake import Snowflake +if TYPE_CHECKING: + from .channel import ChannelType + from .emoji import PartialEmoji + from .snowflake import Snowflake ComponentType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18] ButtonStyle = Literal[1, 2, 3, 4, 5, 6] diff --git a/disnake/types/emoji.py b/disnake/types/emoji.py index 76ac0f423b..53f6f47b3b 100644 --- a/disnake/types/emoji.py +++ b/disnake/types/emoji.py @@ -1,9 +1,11 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Optional, TypedDict +from typing import TYPE_CHECKING, List, Optional, TypedDict -from .snowflake import Snowflake, SnowflakeList -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake, SnowflakeList + from .user import User class PartialEmoji(TypedDict): diff --git a/disnake/types/entitlement.py b/disnake/types/entitlement.py index 1ffacf61ab..0ef488f1e5 100644 --- a/disnake/types/entitlement.py +++ b/disnake/types/entitlement.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Literal, TypedDict +from typing import TYPE_CHECKING, Literal, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake EntitlementType = Literal[1, 2, 3, 4, 5, 6, 7, 8] diff --git a/disnake/types/gateway.py b/disnake/types/gateway.py index 31797bbf15..b6cce9edaa 100644 --- a/disnake/types/gateway.py +++ b/disnake/types/gateway.py @@ -2,32 +2,39 @@ from __future__ import annotations -from typing import Any, List, Literal, Optional, Sequence, Tuple, TypedDict, Union +from typing import TYPE_CHECKING, Any, List, Literal, Optional, Sequence, Tuple, TypedDict, Union from typing_extensions import NotRequired -from .activity import PartialPresenceUpdate, PresenceData, SendableActivity -from .appinfo import PartialAppInfo, PartialGatewayAppInfo +from .activity import PartialPresenceUpdate from .audit_log import AuditLogEntry -from .automod import AutoModAction, AutoModRule, AutoModTriggerType +from .automod import AutoModRule from .channel import Channel, GuildChannel, StageInstance -from .emoji import Emoji, PartialEmoji from .entitlement import Entitlement from .guild import Guild, UnavailableGuild from .guild_scheduled_event import GuildScheduledEvent from .integration import BaseIntegration from .interactions import BaseInteraction, GuildApplicationCommandPermissions -from .invite import InviteTargetType, InviteType from .member import MemberWithUser from .message import Message -from .role import Role -from .snowflake import Snowflake, SnowflakeList from .soundboard import GuildSoundboardSound -from .sticker import GuildSticker from .subscription import Subscription -from .threads import Thread, ThreadMember, ThreadMemberWithPresence, ThreadType -from .user import AvatarDecorationData, User -from .voice import GuildVoiceState, SupportedModes, VoiceChannelEffect +from .threads import Thread, ThreadMember +from .user import User +from .voice import GuildVoiceState, VoiceChannelEffect + +if TYPE_CHECKING: + from .activity import PresenceData, SendableActivity + from .appinfo import PartialAppInfo, PartialGatewayAppInfo + from .automod import AutoModAction, AutoModTriggerType + from .emoji import Emoji, PartialEmoji + from .invite import InviteTargetType, InviteType + from .role import Role + from .snowflake import Snowflake, SnowflakeList + from .sticker import GuildSticker + from .threads import ThreadMemberWithPresence, ThreadType + from .user import AvatarDecorationData + from .voice import SupportedModes class SessionStartLimit(TypedDict): diff --git a/disnake/types/guild.py b/disnake/types/guild.py index d76907940d..8ffc12aff2 100644 --- a/disnake/types/guild.py +++ b/disnake/types/guild.py @@ -1,22 +1,27 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .activity import PartialPresenceUpdate -from .channel import CreateGuildChannel, GuildChannel, StageInstance -from .emoji import Emoji -from .guild_scheduled_event import GuildScheduledEvent -from .member import Member -from .role import CreateRole, Role -from .snowflake import Snowflake -from .soundboard import GuildSoundboardSound -from .sticker import GuildSticker -from .threads import Thread -from .user import User -from .voice import GuildVoiceState -from .welcome_screen import WelcomeScreen +from .channel import CreateGuildChannel +from .role import CreateRole + +if TYPE_CHECKING: + from .activity import PartialPresenceUpdate + from .channel import GuildChannel, StageInstance + from .emoji import Emoji + from .guild_scheduled_event import GuildScheduledEvent + from .member import Member + from .role import Role + from .snowflake import Snowflake + from .soundboard import GuildSoundboardSound + from .sticker import GuildSticker + from .threads import Thread + from .user import User + from .voice import GuildVoiceState + from .welcome_screen import WelcomeScreen class Ban(TypedDict): diff --git a/disnake/types/guild_scheduled_event.py b/disnake/types/guild_scheduled_event.py index b770fe9f7e..50da9da4ee 100644 --- a/disnake/types/guild_scheduled_event.py +++ b/disnake/types/guild_scheduled_event.py @@ -1,12 +1,14 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Literal, Optional, TypedDict +from typing import TYPE_CHECKING, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .member import Member -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .member import Member + from .snowflake import Snowflake + from .user import User GuildScheduledEventPrivacyLevel = Literal[2] GuildScheduledEventStatus = Literal[1, 2, 3, 4] diff --git a/disnake/types/integration.py b/disnake/types/integration.py index d12ff6f958..d4f24b0bb2 100644 --- a/disnake/types/integration.py +++ b/disnake/types/integration.py @@ -2,12 +2,13 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + from .user import User class IntegrationApplication(TypedDict): diff --git a/disnake/types/interactions.py b/disnake/types/interactions.py index c24af62299..c1d612f776 100644 --- a/disnake/types/interactions.py +++ b/disnake/types/interactions.py @@ -4,22 +4,23 @@ from typing import TYPE_CHECKING, Dict, List, Literal, Optional, TypedDict, Union -from .appinfo import ApplicationIntegrationType -from .channel import ChannelType -from .components import MessageTopLevelComponent, Modal -from .embed import Embed -from .entitlement import Entitlement -from .i18n import LocalizationDict -from .member import Member, MemberWithUser -from .role import Role +from .components import Modal from .snowflake import Snowflake -from .threads import ThreadMetadata -from .user import User if TYPE_CHECKING: from typing_extensions import NotRequired, TypeAlias + from .appinfo import ApplicationIntegrationType + from .channel import ChannelType + from .components import MessageTopLevelComponent + from .embed import Embed + from .entitlement import Entitlement + from .i18n import LocalizationDict + from .member import Member, MemberWithUser from .message import AllowedMentions, Attachment, Message + from .role import Role + from .threads import ThreadMetadata + from .user import User ApplicationCommandType = Literal[1, 2, 3] diff --git a/disnake/types/invite.py b/disnake/types/invite.py index 2f1906d5f9..45c18f2564 100644 --- a/disnake/types/invite.py +++ b/disnake/types/invite.py @@ -2,15 +2,16 @@ from __future__ import annotations -from typing import Literal, Optional, TypedDict +from typing import TYPE_CHECKING, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .appinfo import PartialAppInfo -from .channel import InviteChannel -from .guild import InviteGuild -from .guild_scheduled_event import GuildScheduledEvent -from .user import PartialUser +if TYPE_CHECKING: + from .appinfo import PartialAppInfo + from .channel import InviteChannel + from .guild import InviteGuild + from .guild_scheduled_event import GuildScheduledEvent + from .user import PartialUser InviteType = Literal[0, 1, 2] InviteTargetType = Literal[1, 2] diff --git a/disnake/types/member.py b/disnake/types/member.py index 0cb38823c1..c9a61822f4 100644 --- a/disnake/types/member.py +++ b/disnake/types/member.py @@ -1,11 +1,15 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Optional, TypedDict +from typing import TYPE_CHECKING, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import SnowflakeList -from .user import AvatarDecorationData, User +from .user import User + +if TYPE_CHECKING: + from .snowflake import SnowflakeList + from .user import AvatarDecorationData class BaseMember(TypedDict): diff --git a/disnake/types/message.py b/disnake/types/message.py index 993b9de79e..59013c69f3 100644 --- a/disnake/types/message.py +++ b/disnake/types/message.py @@ -2,21 +2,26 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired -from .channel import ChannelType -from .components import MessageTopLevelComponent -from .embed import Embed -from .emoji import PartialEmoji -from .interactions import InteractionDataResolved, InteractionMessageReference, InteractionMetadata -from .member import Member, UserWithMember -from .poll import Poll -from .snowflake import Snowflake, SnowflakeList -from .sticker import StickerItem -from .threads import Thread -from .user import User +if TYPE_CHECKING: + from .channel import ChannelType + from .components import MessageTopLevelComponent + from .embed import Embed + from .emoji import PartialEmoji + from .interactions import ( + InteractionDataResolved, + InteractionMessageReference, + InteractionMetadata, + ) + from .member import Member, UserWithMember + from .poll import Poll + from .snowflake import Snowflake, SnowflakeList + from .sticker import StickerItem + from .threads import Thread + from .user import User class ChannelMention(TypedDict): diff --git a/disnake/types/onboarding.py b/disnake/types/onboarding.py index 79d1bb86a2..82fe709207 100644 --- a/disnake/types/onboarding.py +++ b/disnake/types/onboarding.py @@ -1,9 +1,11 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict -from .emoji import Emoji -from .snowflake import Snowflake, SnowflakeList +if TYPE_CHECKING: + from .emoji import Emoji + from .snowflake import Snowflake, SnowflakeList OnboardingPromptType = Literal[0, 1] diff --git a/disnake/types/poll.py b/disnake/types/poll.py index 37d33e2206..f270dc6760 100644 --- a/disnake/types/poll.py +++ b/disnake/types/poll.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .emoji import PartialEmoji -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .emoji import PartialEmoji + from .snowflake import Snowflake + from .user import User class PollMedia(TypedDict): diff --git a/disnake/types/role.py b/disnake/types/role.py index cc5e105779..8cb300829e 100644 --- a/disnake/types/role.py +++ b/disnake/types/role.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import Optional, TypedDict +from typing import TYPE_CHECKING, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake class Role(TypedDict): diff --git a/disnake/types/sku.py b/disnake/types/sku.py index 83614af6bb..4a5ecb2b5c 100644 --- a/disnake/types/sku.py +++ b/disnake/types/sku.py @@ -1,8 +1,10 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Literal, TypedDict +from typing import TYPE_CHECKING, Literal, TypedDict -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake SKUType = Literal[2, 3, 5, 6] diff --git a/disnake/types/soundboard.py b/disnake/types/soundboard.py index 333d7033b3..77538c2e21 100644 --- a/disnake/types/soundboard.py +++ b/disnake/types/soundboard.py @@ -2,12 +2,13 @@ from __future__ import annotations -from typing import List, Optional, TypedDict +from typing import TYPE_CHECKING, List, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + from .user import User class PartialSoundboardSound(TypedDict): diff --git a/disnake/types/sticker.py b/disnake/types/sticker.py index 06bc58aa05..4fcd2f365f 100644 --- a/disnake/types/sticker.py +++ b/disnake/types/sticker.py @@ -2,12 +2,13 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict, Union +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict, Union from typing_extensions import NotRequired -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + from .user import User StickerFormatType = Literal[1, 2, 3, 4] diff --git a/disnake/types/subscription.py b/disnake/types/subscription.py index 1cfaaf8684..f3301c5de4 100644 --- a/disnake/types/subscription.py +++ b/disnake/types/subscription.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake SubscriptionStatus = Literal[0, 1, 2] diff --git a/disnake/types/team.py b/disnake/types/team.py index 0829c18b5c..8687cf60ac 100644 --- a/disnake/types/team.py +++ b/disnake/types/team.py @@ -2,10 +2,11 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict -from .snowflake import Snowflake -from .user import PartialUser +if TYPE_CHECKING: + from .snowflake import Snowflake + from .user import PartialUser TeamMembershipState = Literal[1, 2] TeamMemberRole = Literal["admin", "developer", "read_only"] diff --git a/disnake/types/template.py b/disnake/types/template.py index e0008659aa..e7e186f102 100644 --- a/disnake/types/template.py +++ b/disnake/types/template.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import Optional, TypedDict +from typing import TYPE_CHECKING, Optional, TypedDict -from .guild import Guild -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .guild import Guild + from .snowflake import Snowflake + from .user import User class CreateTemplate(TypedDict): diff --git a/disnake/types/threads.py b/disnake/types/threads.py index 30f630d916..f70758cb2a 100644 --- a/disnake/types/threads.py +++ b/disnake/types/threads.py @@ -2,14 +2,15 @@ from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .activity import PresenceData -from .member import Member -from .message import Message -from .snowflake import Snowflake, SnowflakeList +if TYPE_CHECKING: + from .activity import PresenceData + from .member import Member + from .message import Message + from .snowflake import Snowflake, SnowflakeList ThreadType = Literal[10, 11, 12] ThreadArchiveDurationLiteral = Literal[60, 1440, 4320, 10080] diff --git a/disnake/types/user.py b/disnake/types/user.py index 06fdb33fb9..acc8475822 100644 --- a/disnake/types/user.py +++ b/disnake/types/user.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import Literal, Optional, TypedDict +from typing import TYPE_CHECKING, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake PaletteType = Literal[ "crimson", diff --git a/disnake/types/voice.py b/disnake/types/voice.py index 3b59312ddf..fde5f66168 100644 --- a/disnake/types/voice.py +++ b/disnake/types/voice.py @@ -1,12 +1,14 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Literal, Optional, TypedDict +from typing import TYPE_CHECKING, List, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .emoji import PartialEmoji -from .member import MemberWithUser -from .snowflake import Snowflake +if TYPE_CHECKING: + from .emoji import PartialEmoji + from .member import MemberWithUser + from .snowflake import Snowflake SupportedModes = Literal[ # "aead_aes256_gcm_rtpsize", # supported in libsodium, but not exposed by pynacl diff --git a/disnake/types/webhook.py b/disnake/types/webhook.py index 5a31205f29..83f954b51d 100644 --- a/disnake/types/webhook.py +++ b/disnake/types/webhook.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import Literal, Optional, TypedDict +from typing import TYPE_CHECKING, Literal, Optional, TypedDict from typing_extensions import NotRequired -from .channel import PartialChannel -from .snowflake import Snowflake -from .user import User +if TYPE_CHECKING: + from .channel import PartialChannel + from .snowflake import Snowflake + from .user import User class SourceGuild(TypedDict): diff --git a/disnake/types/welcome_screen.py b/disnake/types/welcome_screen.py index e98b7c3668..049b3d30a5 100644 --- a/disnake/types/welcome_screen.py +++ b/disnake/types/welcome_screen.py @@ -2,9 +2,10 @@ from __future__ import annotations -from typing import List, Optional, TypedDict +from typing import TYPE_CHECKING, List, Optional, TypedDict -from .snowflake import Snowflake +if TYPE_CHECKING: + from .snowflake import Snowflake class WelcomeScreen(TypedDict): diff --git a/disnake/types/widget.py b/disnake/types/widget.py index df011ac1a5..c1cd1bf82b 100644 --- a/disnake/types/widget.py +++ b/disnake/types/widget.py @@ -1,10 +1,13 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations -from typing import List, Optional, TypedDict +from typing import TYPE_CHECKING, List, Optional, TypedDict -from .snowflake import Snowflake from .user import User +if TYPE_CHECKING: + from .snowflake import Snowflake + class WidgetChannel(TypedDict): id: Snowflake diff --git a/disnake/ui/action_row.py b/disnake/ui/action_row.py index 062297dde4..108b4de030 100644 --- a/disnake/ui/action_row.py +++ b/disnake/ui/action_row.py @@ -25,8 +25,6 @@ from ..components import ( ActionRow as ActionRowComponent, - ActionRowChildComponent, - ActionRowMessageComponent as ActionRowMessageComponentRaw, Button as ButtonComponent, ChannelSelectMenu as ChannelSelectComponent, Component, @@ -44,15 +42,13 @@ Thumbnail as ThumbnailComponent, UserSelectMenu as UserSelectComponent, ) -from ..enums import ButtonStyle, ChannelType, ComponentType, TextInputStyle +from ..enums import ButtonStyle, ComponentType, TextInputStyle from ..utils import MISSING, SequenceProxy, assert_never, copy_doc, deprecated from ._types import ( ActionRowChildT, ActionRowMessageComponent, ActionRowModalComponent, ComponentInput, - MessageTopLevelComponent, - NonActionRowChildT, ) from .button import Button from .container import Container @@ -71,7 +67,12 @@ from typing_extensions import Self, TypeAlias from ..abc import AnyChannel + from ..components import ( + ActionRowChildComponent, + ActionRowMessageComponent as ActionRowMessageComponentRaw, + ) from ..emoji import Emoji + from ..enums import ChannelType from ..member import Member from ..message import Message from ..partial_emoji import PartialEmoji @@ -81,6 +82,10 @@ MessageTopLevelComponent as MessageTopLevelComponentPayload, ) from ..user import User + from ._types import ( + MessageTopLevelComponent, + NonActionRowChildT, + ) from .select.base import SelectDefaultValueInputType, SelectDefaultValueMultiInputType from .select.string import SelectOptionInput diff --git a/disnake/ui/button.py b/disnake/ui/button.py index 313bd1f065..0d93092010 100644 --- a/disnake/ui/button.py +++ b/disnake/ui/button.py @@ -9,7 +9,7 @@ from ..enums import ButtonStyle, ComponentType from ..partial_emoji import PartialEmoji, _EmojiTag from ..utils import MISSING, iscoroutinefunction -from .item import DecoratedItem, Item +from .item import Item __all__ = ( "Button", @@ -20,7 +20,7 @@ from typing_extensions import ParamSpec, Self from ..emoji import Emoji - from .item import ItemCallbackType + from .item import DecoratedItem, ItemCallbackType from .view import View else: diff --git a/disnake/ui/file.py b/disnake/ui/file.py index cade201337..6fcafaef68 100644 --- a/disnake/ui/file.py +++ b/disnake/ui/file.py @@ -5,7 +5,7 @@ import copy from typing import TYPE_CHECKING, ClassVar, Optional, Tuple -from ..components import FileComponent, UnfurledMediaItem, handle_media_item_input +from ..components import FileComponent, handle_media_item_input from ..enums import ComponentType from ..utils import MISSING from .item import UIComponent @@ -13,7 +13,7 @@ if TYPE_CHECKING: from typing_extensions import Self - from ..components import LocalMediaItemInput + from ..components import LocalMediaItemInput, UnfurledMediaItem __all__ = ("File",) diff --git a/disnake/ui/media_gallery.py b/disnake/ui/media_gallery.py index b05b9073dc..5a1e3e05cd 100644 --- a/disnake/ui/media_gallery.py +++ b/disnake/ui/media_gallery.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, ClassVar, List, Sequence, Tuple -from ..components import MediaGallery as MediaGalleryComponent, MediaGalleryItem +from ..components import MediaGallery as MediaGalleryComponent from ..enums import ComponentType from ..utils import MISSING from .item import UIComponent @@ -12,6 +12,8 @@ if TYPE_CHECKING: from typing_extensions import Self + from ..components import MediaGalleryItem + __all__ = ("MediaGallery",) diff --git a/disnake/ui/select/base.py b/disnake/ui/select/base.py index 832cab3c0b..050ea02324 100644 --- a/disnake/ui/select/base.py +++ b/disnake/ui/select/base.py @@ -20,10 +20,9 @@ ) from ...components import AnySelectMenu, SelectDefaultValue -from ...enums import ComponentType, SelectDefaultValueType from ...object import Object from ...utils import MISSING, humanize_list, iscoroutinefunction -from ..item import DecoratedItem, Item +from ..item import Item __all__ = ("BaseSelect",) @@ -31,8 +30,9 @@ from typing_extensions import ParamSpec, Self from ...abc import Snowflake + from ...enums import ComponentType, SelectDefaultValueType from ...interactions import MessageInteraction - from ..item import ItemCallbackType + from ..item import DecoratedItem, ItemCallbackType from ..view import View else: diff --git a/disnake/ui/select/channel.py b/disnake/ui/select/channel.py index 15e8f0580b..037d9b21f0 100644 --- a/disnake/ui/select/channel.py +++ b/disnake/ui/select/channel.py @@ -17,20 +17,21 @@ overload, ) -from ...abc import GuildChannel, Snowflake +from ...abc import GuildChannel from ...channel import DMChannel, GroupChannel, PartialMessageable from ...components import ChannelSelectMenu from ...enums import ChannelType, ComponentType, SelectDefaultValueType from ...object import Object from ...threads import Thread from ...utils import MISSING -from .base import BaseSelect, P, SelectDefaultValueInputType, V_co, _create_decorator +from .base import BaseSelect, V_co, _create_decorator if TYPE_CHECKING: from typing_extensions import Self - from ...abc import AnyChannel + from ...abc import AnyChannel, Snowflake from ..item import DecoratedItem, ItemCallbackType + from .base import P, SelectDefaultValueInputType __all__ = ( diff --git a/disnake/ui/select/mentionable.py b/disnake/ui/select/mentionable.py index 8c258f4b5d..f8d7b34ef2 100644 --- a/disnake/ui/select/mentionable.py +++ b/disnake/ui/select/mentionable.py @@ -17,19 +17,20 @@ overload, ) -from ...abc import Snowflake from ...components import MentionableSelectMenu from ...enums import ComponentType, SelectDefaultValueType from ...member import Member from ...role import Role from ...user import ClientUser, User from ...utils import MISSING -from .base import BaseSelect, P, SelectDefaultValueMultiInputType, V_co, _create_decorator +from .base import BaseSelect, V_co, _create_decorator if TYPE_CHECKING: from typing_extensions import Self + from ...abc import Snowflake from ..item import DecoratedItem, ItemCallbackType + from .base import P, SelectDefaultValueMultiInputType __all__ = ( diff --git a/disnake/ui/select/role.py b/disnake/ui/select/role.py index 99c06086bf..d7ec942b36 100644 --- a/disnake/ui/select/role.py +++ b/disnake/ui/select/role.py @@ -16,18 +16,19 @@ overload, ) -from ...abc import Snowflake from ...components import RoleSelectMenu from ...enums import ComponentType, SelectDefaultValueType from ...object import Object from ...role import Role from ...utils import MISSING -from .base import BaseSelect, P, SelectDefaultValueInputType, V_co, _create_decorator +from .base import BaseSelect, V_co, _create_decorator if TYPE_CHECKING: from typing_extensions import Self + from ...abc import Snowflake from ..item import DecoratedItem, ItemCallbackType + from .base import P, SelectDefaultValueInputType __all__ = ( diff --git a/disnake/ui/select/string.py b/disnake/ui/select/string.py index 54c257e49f..af6bb4b96a 100644 --- a/disnake/ui/select/string.py +++ b/disnake/ui/select/string.py @@ -18,18 +18,20 @@ overload, ) -from ...abc import Snowflake from ...components import SelectOption, StringSelectMenu -from ...enums import ComponentType, SelectDefaultValueType +from ...enums import ComponentType from ...utils import MISSING -from .base import BaseSelect, P, V_co, _create_decorator +from .base import BaseSelect, V_co, _create_decorator if TYPE_CHECKING: from typing_extensions import Self + from ...abc import Snowflake from ...emoji import Emoji + from ...enums import SelectDefaultValueType from ...partial_emoji import PartialEmoji from ..item import DecoratedItem, ItemCallbackType + from .base import P __all__ = ( diff --git a/disnake/ui/select/user.py b/disnake/ui/select/user.py index 858a3770ba..45756fc537 100644 --- a/disnake/ui/select/user.py +++ b/disnake/ui/select/user.py @@ -17,19 +17,20 @@ overload, ) -from ...abc import Snowflake from ...components import UserSelectMenu from ...enums import ComponentType, SelectDefaultValueType from ...member import Member from ...object import Object from ...user import ClientUser, User from ...utils import MISSING -from .base import BaseSelect, P, SelectDefaultValueInputType, V_co, _create_decorator +from .base import BaseSelect, V_co, _create_decorator if TYPE_CHECKING: from typing_extensions import Self + from ...abc import Snowflake from ..item import DecoratedItem, ItemCallbackType + from .base import P, SelectDefaultValueInputType __all__ = ( diff --git a/disnake/ui/thumbnail.py b/disnake/ui/thumbnail.py index 2b15fc6b92..aec4a88661 100644 --- a/disnake/ui/thumbnail.py +++ b/disnake/ui/thumbnail.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, ClassVar, Optional, Tuple -from ..components import Thumbnail as ThumbnailComponent, UnfurledMediaItem, handle_media_item_input +from ..components import Thumbnail as ThumbnailComponent, handle_media_item_input from ..enums import ComponentType from ..utils import MISSING from .item import UIComponent @@ -12,7 +12,7 @@ if TYPE_CHECKING: from typing_extensions import Self - from ..components import MediaItemInput + from ..components import MediaItemInput, UnfurledMediaItem __all__ = ("Thumbnail",) diff --git a/disnake/webhook/sync.py b/disnake/webhook/sync.py index d5753f0aa9..05b3597b03 100644 --- a/disnake/webhook/sync.py +++ b/disnake/webhook/sync.py @@ -31,7 +31,6 @@ from .. import utils from ..channel import PartialMessageable from ..errors import DiscordServerError, Forbidden, HTTPException, NotFound, WebhookTokenMissing -from ..flags import MessageFlags from ..http import Route from ..message import Message from ..object import Object @@ -52,6 +51,7 @@ from ..abc import Snowflake from ..embeds import Embed from ..file import File + from ..flags import MessageFlags from ..mentions import AllowedMentions from ..message import Attachment from ..types.message import Message as MessagePayload diff --git a/disnake/widget.py b/disnake/widget.py index b6041991b4..3e47ab170b 100644 --- a/disnake/widget.py +++ b/disnake/widget.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union -from .activity import BaseActivity, Spotify, create_activity +from .activity import create_activity from .asset import Asset from .enums import Status, WidgetStyle, try_enum from .invite import Invite @@ -15,6 +15,7 @@ import datetime from .abc import GuildChannel, Snowflake + from .activity import BaseActivity, Spotify from .guild import Guild from .state import ConnectionState from .types.widget import ( diff --git a/docs/conf.py b/docs/conf.py index 44074457ec..06c1a8c2bd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,6 +11,7 @@ # # All configuration values have a default; values that are commented out # serve to show the default. +from __future__ import annotations import importlib.util import inspect @@ -18,9 +19,10 @@ import re import subprocess # noqa: TID251 import sys -from typing import Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, Optional -from sphinx.application import Sphinx +if TYPE_CHECKING: + from sphinx.application import Sphinx # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/docs/extensions/redirects.py b/docs/extensions/redirects.py index 46114dd743..984541cfd8 100644 --- a/docs/extensions/redirects.py +++ b/docs/extensions/redirects.py @@ -5,10 +5,11 @@ from pathlib import Path from typing import TYPE_CHECKING, Dict -from sphinx.application import Sphinx from sphinx.util.fileutil import copy_asset_file if TYPE_CHECKING: + from sphinx.application import Sphinx + from ._types import SphinxExtensionMeta SCRIPT_PATH = "_templates/api_redirect.js_t" diff --git a/pyproject.toml b/pyproject.toml index 28e6b509e0..a97816651a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,10 +171,6 @@ ignore = [ "TID252", # we still use relative imports ## flake8-todos "TD", # similar to flake8-fixme, though they may conflict - ## flake8-typechecking - "TC001", # typing-only first party import # to be enabled - "TC002", # typing only standard library import # to be enabled - "TC003", # typing only third party import # to be enabled ## flake8-unused-arguments "ARG", # most unused arguments are intentional ## flake8-use-pathlib diff --git a/scripts/codemods/combined.py b/scripts/codemods/combined.py index 306be23d7c..364279e007 100644 --- a/scripts/codemods/combined.py +++ b/scripts/codemods/combined.py @@ -1,13 +1,17 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations import functools +from typing import TYPE_CHECKING -import libcst as cst from libcst import codemod from . import link_doc_types, overloads_no_missing, typed_flags, typed_permissions from .base import NoMetadataWrapperMixin +if TYPE_CHECKING: + import libcst as cst + CODEMODS = [ overloads_no_missing.EllipsisOverloads, typed_flags.FlagTypings, diff --git a/scripts/codemods/typed_flags.py b/scripts/codemods/typed_flags.py index af6c12a386..5a6d84522f 100644 --- a/scripts/codemods/typed_flags.py +++ b/scripts/codemods/typed_flags.py @@ -1,9 +1,9 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations import importlib import textwrap -import types -from typing import List, Optional, cast +from typing import TYPE_CHECKING, List, Optional, cast import libcst as cst import libcst.codemod.visitors as codevisitors @@ -14,6 +14,9 @@ from .base import BaseCodemodCommand +if TYPE_CHECKING: + import types + BASE_FLAG_CLASSES = (flags.BaseFlags, flags.ListBaseFlags) MODULES = ( diff --git a/tests/helpers.py b/tests/helpers.py index bcf957d98e..ab67022cb2 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,14 +1,16 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations import datetime import functools import inspect -import types from typing import TYPE_CHECKING, Callable, ContextManager, Optional, Type, TypeVar from unittest import mock if TYPE_CHECKING: # for pyright + import types + from typing_extensions import reveal_type as reveal_type else: # to avoid flake8 noqas diff --git a/tests/test_utils.py b/tests/test_utils.py index fcc1ed60e8..3f3c2b69e4 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ # SPDX-License-Identifier: MIT +from __future__ import annotations import asyncio import datetime @@ -1017,7 +1018,7 @@ def inner() -> None: ... def decorated(self) -> None: ... # we cannot stringify this file due to it testing annotation resolving - _lambda: Callable[["_Clazz"], None] = lambda _: None # noqa: UP037 + _lambda: Callable[[_Clazz], None] = lambda _: None @pytest.mark.parametrize(