From 43d6976c21d7d6fdb358a0faf5bb6300ddb81e7e Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Sun, 12 Oct 2025 23:10:17 +0200 Subject: [PATCH 1/2] :bug: Handle python 3.12+ `TypeAliasType` in `Option` parsing --- discord/commands/options.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/discord/commands/options.py b/discord/commands/options.py index c3bfafe888..ac8e4d3a6d 100644 --- a/discord/commands/options.py +++ b/discord/commands/options.py @@ -28,7 +28,15 @@ import logging import types from enum import Enum -from typing import TYPE_CHECKING, Literal, Optional, Type, Union, get_args +from typing import ( + TYPE_CHECKING, + Literal, + Optional, + Type, + TypeAliasType, + Union, + get_args, +) from ..abc import GuildChannel, Mentionable from ..channel import ( @@ -197,6 +205,7 @@ def __init__( if self.name is not None: self.name = str(self.name) self._parameter_name = self.name # default + input_type = self._parse_type_alias(input_type) input_type = self._strip_none_type(input_type) self._raw_type: InputType | tuple = input_type @@ -367,6 +376,12 @@ def __init__( if input_type is None: raise TypeError("input_type cannot be NoneType.") + @staticmethod + def _parse_type_alias(input_type: InputType) -> InputType: + if isinstance(input_type, TypeAliasType): + return input_type.__value__ + return input_type + @staticmethod def _strip_none_type(input_type): if isinstance(input_type, SlashCommandOptionType): From f71b8b462a1f6c428d8a3ffb0c98c76583d239f6 Mon Sep 17 00:00:00 2001 From: Paillat-dev Date: Sun, 12 Oct 2025 23:14:19 +0200 Subject: [PATCH 2/2] :memo: CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01e0f2b8fd..784c389908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2925](https://github.com/Pycord-Development/pycord/pull/2925)) - Fixed a `TypeError` when typing `ui.Select` without providing optional type arguments. ([#2943](https://github.com/Pycord-Development/pycord/pull/2943)) +- Fixed `TypeError` when using Python 3.12+ `type` syntax for typing slash command + parameters. ([#2952](https://github.com/Pycord-Development/pycord/pull/2952)) ### Removed