Skip to content

Commit

Permalink
fix: Correct regression from pull #2124 (#2126)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
afroemming committed Jun 16, 2023
1 parent d894a58 commit ca2f5da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions discord/commands/core.py
Expand Up @@ -30,6 +30,7 @@
import functools
import inspect
import re
import sys
import types
from collections import OrderedDict
from enum import Enum
Expand All @@ -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
Expand All @@ -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",
Expand Down

0 comments on commit ca2f5da

Please sign in to comment.