Browse Source

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.
pull/10452/head
Michael Hall 3 weeks ago
parent
commit
6d8cfc6a88
  1. 3
      discord/ext/commands/converter.py

3
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,)

Loading…
Cancel
Save