From 7057cb10c04572cdf26158f702e7970a08c079f1 Mon Sep 17 00:00:00 2001 From: Michael H Date: Wed, 8 Jul 2026 16:15:06 -0400 Subject: [PATCH] Allow Greedy[X] | Y Constructs a Union. Needs to be special instance behavior due to `__class_getitem__` being implemented to return an instance not a type or GenericAlias. --- discord/ext/commands/converter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index a4b9b3b7d..c5ed0413c 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -1140,6 +1140,9 @@ class Greedy(List[T]): converter = getattr(self.converter, '__name__', repr(self.converter)) return f'Greedy[{converter}]' + def __or__(self, value: Any) -> Any: + return Union[self, value] + def __class_getitem__(cls, params: Union[Tuple[T], T]) -> Greedy[T]: if not isinstance(params, tuple): params = (params,)