From fb024546ffd12cda771bb58a762b2ebc824f0299 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 24 Apr 2021 08:55:55 -0400 Subject: [PATCH] [commands] Fix Literal converter not working within flags --- discord/ext/commands/flags.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/discord/ext/commands/flags.py b/discord/ext/commands/flags.py index 68a02911d..6bbfb00ba 100644 --- a/discord/ext/commands/flags.py +++ b/discord/ext/commands/flags.py @@ -41,6 +41,7 @@ from dataclasses import dataclass, field from typing import ( Dict, Iterator, + Literal, Optional, Pattern, Set, @@ -230,6 +231,9 @@ def get_flags(namespace: Dict[str, Any], globals: Dict[str, Any], locals: Dict[s flag.max_args = -1 if flag.override is MISSING: flag.override = True + elif origin is Literal: + if flag.max_args is MISSING: + flag.max_args = 1 else: raise TypeError(f'Unsupported typing annotation {annotation!r} for {flag.name!r} flag')