Skip to content

Commit a005291

Browse files
committed
fix: Option type handling for multiple Literals
Updates Option type resolution to return a Union of Literals when all filtered types are Literal, ensuring correct type annotation for command options.
1 parent 9df56ac commit a005291

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

discord/commands/options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,9 @@ def _strip_none_type(input_type):
386386
raise TypeError("Option type cannot be only NoneType")
387387
if len(filtered) == 1:
388388
return filtered[0]
389-
return filtered
390-
389+
if all(getattr(t, "__origin__", None) is Literal for t in filtered):
390+
return Union[filtered]
391+
return Union[filtered]
391392
return input_type
392393

393394
def to_dict(self) -> dict:

0 commit comments

Comments
 (0)