Skip to content

Commit 6d19bc7

Browse files
committed
[commands] Fix flag annotations not working under 3.14
1 parent be3e332 commit 6d19bc7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

discord/ext/commands/flags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ def validate_flag_name(name: str, forbidden: Set[str]) -> None:
178178

179179
def get_flags(namespace: Dict[str, Any], globals: Dict[str, Any], locals: Dict[str, Any]) -> Dict[str, Flag]:
180180
annotations = namespace.get('__annotations__', {})
181+
if '__annotate__' in namespace:
182+
# In Python 3.14, classes no longer get `__annotations__` and instead a function
183+
# under __annotate__ is used instead that that takes a format argument on how to
184+
# receive those annotations.
185+
# Format 1 is full value, Format 3 is value and ForwardRef for undefined ones
186+
# So format 3 is the one we're typically used to
187+
annotations = namespace['__annotate__'](3)
188+
181189
case_insensitive = namespace['__commands_flag_case_insensitive__']
182190
flags: Dict[str, Flag] = {}
183191
cache: Dict[str, Any] = {}

0 commit comments

Comments
 (0)