Skip to content

Commit

Permalink
CR fix: add isinstance check
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Jul 8, 2022
1 parent e8b09d3 commit 2dffa0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aiogram/dispatcher/filters/builtin.py
Expand Up @@ -69,7 +69,11 @@ def __init__(self, commands: Union[Iterable[Union[str, BotCommand]], str, BotCom
if isinstance(commands, (str, BotCommand)):
commands = (commands,)
elif isinstance(commands, Iterable):
pass
if not all(map(lambda cmd: isinstance(cmd, str), commands)):
raise ValueError(
"Command filter doesn't support {} as input. "
"It only supports str, BotCommand object or their Iterable"
)
else:
raise ValueError(
"Command filter doesn't support {} as input. "
Expand Down
7 changes: 7 additions & 0 deletions tests/test_dispatcher/test_filters/test_builtin.py
Expand Up @@ -139,3 +139,10 @@ async def test_commands_filter_not_checked():
start_filter = Command(commands=["help", BotCommand("about", "my desc")])

assert not await start_filter.check(message_with_command)


@pytest.mark.asyncio
async def test_commands_filter_not_checked():
with pytest.raises(ValueError):
start_filter = Command(commands=42) # noqa

0 comments on commit 2dffa0e

Please sign in to comment.