mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
CR fix: add isinstance check
This commit is contained in:
parent
e8b09d3fcf
commit
2dffa0e3dd
2 changed files with 12 additions and 1 deletions
|
|
@ -69,7 +69,11 @@ class Command(Filter):
|
||||||
if isinstance(commands, (str, BotCommand)):
|
if isinstance(commands, (str, BotCommand)):
|
||||||
commands = (commands,)
|
commands = (commands,)
|
||||||
elif isinstance(commands, Iterable):
|
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:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Command filter doesn't support {} as input. "
|
"Command filter doesn't support {} as input. "
|
||||||
|
|
|
||||||
|
|
@ -139,3 +139,10 @@ async def test_commands_filter_not_checked():
|
||||||
start_filter = Command(commands=["help", BotCommand("about", "my desc")])
|
start_filter = Command(commands=["help", BotCommand("about", "my desc")])
|
||||||
|
|
||||||
assert not await start_filter.check(message_with_command)
|
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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue