mirror of
https://github.com/Rapptz/discord.py.git
synced 2026-09-20 19:17:42 +00:00
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.
This commit is contained in:
@@ -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,)
|
||||
|
||||
Reference in New Issue
Block a user