From 7a07644de3dad9defe60d44cca7211b7b7f84134 Mon Sep 17 00:00:00 2001 From: Sebastian Law <44045823+SebbyLaw@users.noreply.github.com> Date: Sun, 28 Jun 2020 00:54:34 -0700 Subject: [commands] Raise TypeError when Optional is used with Greedy converter --- discord/ext/commands/converter.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'discord/ext') diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 3d706bf8..123b6699 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -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() -- cgit v1.2.3