Skip to content

Commit

Permalink
Type checking fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed Feb 21, 2024
1 parent 059def9 commit 2f88200
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lightbulb/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ def focused(self) -> hikari.AutocompleteInteractionOption:
def get_option(self, name: str) -> t.Optional[hikari.AutocompleteInteractionOption]:
"""
Get the option with the given name if available.
Args:
name (:obj:`str`): The name of the option to get.
Returns:
:obj:`~typing.Optional` [ :obj:`hikari.interactions.command_interactions.AutocompleteInteractionOption` ]: The
option, or :obj:`None` if not available from the interaction.
See Also:
:obj:`~AutocompleteContext.focused`
""" # noqa: E501
return next(filter(lambda opt: opt.name == name, self.options), None)

@staticmethod
def _normalise_choices(choices: AutocompleteResponseT) -> t.Sequence[special_endpoints.AutocompleteChoiceBuilder]:
if isinstance(choices, dict):
if isinstance(choices, collections.abc.Mapping):
return [hikari.impl.AutocompleteChoiceBuilder(name=k, value=v) for k, v in choices.items()]

def _to_command_choice(
Expand All @@ -121,7 +121,6 @@ def _to_command_choice(

return hikari.impl.AutocompleteChoiceBuilder(name=item[0], value=item[1])

assert not isinstance(choices, collections.abc.Mapping)
return list(map(_to_command_choice, choices))

async def respond(self, choices: AutocompleteResponseT) -> None:
Expand Down

0 comments on commit 2f88200

Please sign in to comment.