From 6d8cfc6a882d1ea933c8bf3628258529ffebdf84 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Mon, 25 May 2026 04:33:50 -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,)