[commands] Raise TypeError when Optional is used with Greedy converter
This commit is contained in:
@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import re
|
||||
import inspect
|
||||
import typing
|
||||
|
||||
import discord
|
||||
|
||||
@ -555,6 +556,9 @@ class _Greedy:
|
||||
if converter is str or converter is type(None) or converter is _Greedy:
|
||||
raise TypeError('Greedy[%s] is invalid.' % converter.__name__)
|
||||
|
||||
if getattr(converter, '__origin__', None) is typing.Union and type(None) in converter.__args__:
|
||||
raise TypeError('Greedy[%r] is invalid.' % converter)
|
||||
|
||||
return self.__class__(converter=converter)
|
||||
|
||||
Greedy = _Greedy()
|
||||
|
Reference in New Issue
Block a user