From ca2f5da1f6918583767a8978c6393a1253fa59c7 Mon Sep 17 00:00:00 2001 From: Amelia Froemming <7919407+afroemming@users.noreply.github.com> Date: Fri, 16 Jun 2023 09:43:08 -0500 Subject: [PATCH] fix: Correct regression from pull #2124 (#2126) Pycord requires typing_extensions as a dependency for python < 3.11, however not on version >= 3.11. Because the changes in the referenced pull always tries to load from typing_extensions, they make it so an exception will be raised if the end user is using python >= 3.11 and does not otherwise have that library installed when _parse_options is run (ie, whenever a command is registered). This change checks the version of python running Pycord, then imports stdlib typing if >= 3.11. --- discord/commands/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/discord/commands/core.py b/discord/commands/core.py index 08649c2827..09222ab72b 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -30,6 +30,7 @@ import functools import inspect import re +import sys import types from collections import OrderedDict from enum import Enum @@ -44,8 +45,6 @@ Union, ) -from typing_extensions import Annotated, get_args, get_origin - from ..channel import _threaded_guild_channel_factory from ..enums import Enum as DiscordEnum from ..enums import MessageType, SlashCommandOptionType, try_enum @@ -66,6 +65,11 @@ from .context import ApplicationContext, AutocompleteContext from .options import Option, OptionChoice +if sys.version_info >= (3, 11): + from typing import Annotated, get_args, get_origin +else: + from typing_extensions import Annotated, get_args, get_origin + __all__ = ( "_BaseCommand", "ApplicationCommand",