@@ -1106,13 +1106,13 @@ async def autocomplete(ctx):
1106
1106
1107
1107
Parameters
1108
1108
-----------
1109
- values: Union[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]], Callable[[:class:`AutocompleteContext`], Union[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]], Awaitable[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]], Awaitable[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]
1109
+ values: Union[Union[Iterable[:class:`OptionChoice`], Iterable[:class:` str`], Iterable[:class:`int`], Iterable[:class:`float`]], Callable[[:class:`AutocompleteContext`], Union[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]], Awaitable[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]], Awaitable[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]
1110
1110
Possible values for the option. Accepts an iterable of :class:`str`, a callable (sync or async) that takes a
1111
1111
single argument of :class:`AutocompleteContext`, or a coroutine. Must resolve to an iterable of :class:`str`.
1112
1112
1113
1113
Returns
1114
1114
--------
1115
- Callable[[:class:`AutocompleteContext`], Awaitable[Union[Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]
1115
+ Callable[[:class:`AutocompleteContext`], Awaitable[Union[Iterable[:class:`OptionChoice`], Iterable[:class:` str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]
1116
1116
A wrapped callback for the autocomplete.
1117
1117
"""
1118
1118
async def autocomplete_callback (ctx : AutocompleteContext ) -> V :
@@ -1123,7 +1123,11 @@ async def autocomplete_callback(ctx: AutocompleteContext) -> V:
1123
1123
if asyncio .iscoroutine (_values ):
1124
1124
_values = await _values
1125
1125
1126
- gen = (val for val in _values if str (val ).lower ().startswith (str (ctx .value or "" ).lower ()))
1126
+ def check (item : Any ) -> bool :
1127
+ item = getattr (item , "name" , item )
1128
+ return str (item ).lower ().startswith (str (ctx .value or "" ).lower ())
1129
+
1130
+ gen = (val for val in _values if check (val ))
1127
1131
return iter (itertools .islice (gen , 25 ))
1128
1132
1129
1133
return autocomplete_callback
0 commit comments