From e8b09d3fcf79878c62d9b9cf66864d347bec227e Mon Sep 17 00:00:00 2001 From: Yuriy Chebyshev Date: Fri, 8 Jul 2022 15:11:18 +0300 Subject: [PATCH] CR fix: add isinstance check --- aiogram/dispatcher/filters/builtin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aiogram/dispatcher/filters/builtin.py b/aiogram/dispatcher/filters/builtin.py index 7a3d4c62e0..ffec60175d 100644 --- a/aiogram/dispatcher/filters/builtin.py +++ b/aiogram/dispatcher/filters/builtin.py @@ -68,8 +68,14 @@ def __init__(self, commands: Union[Iterable[Union[str, BotCommand]], str, BotCom """ if isinstance(commands, (str, BotCommand)): commands = (commands,) - if isinstance(commands, Iterable): - commands = [cmd.command if isinstance(cmd, BotCommand) else cmd for cmd in commands] + elif isinstance(commands, Iterable): + pass + else: + raise ValueError( + "Command filter doesn't support {} as input. " + "It only supports str, BotCommand object or their Iterable" + ) + commands = [cmd.command if isinstance(cmd, BotCommand) else cmd for cmd in commands] self.commands = list(map(str.lower, commands)) if ignore_case else commands self.prefixes = prefixes