From 8c283ee242c1124479cba364cf4923e7eed0f1f7 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Feb 2023 19:14:35 +0200 Subject: [PATCH] fix, attempt to satisfy the linter --- aiogram/filters/command.py | 5 ++--- tests/test_filters/test_command.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiogram/filters/command.py b/aiogram/filters/command.py index 914ea26f..13997073 100644 --- a/aiogram/filters/command.py +++ b/aiogram/filters/command.py @@ -87,14 +87,13 @@ class Command(Filter): "Command filter only supports str, re.Pattern, BotCommand object" " or their Iterable" ) + if ignore_case and isinstance(command, str): + command = command.casefold() items.append(command) if not items: raise ValueError("At least one command should be specified") - if ignore_case: - items = map(str.casefold, items) - self.commands = tuple(items) self.prefix = prefix self.ignore_case = ignore_case diff --git a/tests/test_filters/test_command.py b/tests/test_filters/test_command.py index feca2763..806a5fac 100644 --- a/tests/test_filters/test_command.py +++ b/tests/test_filters/test_command.py @@ -42,6 +42,7 @@ class TestCommandFilter: [("12TeSt", "3t4Est", "5TE6sT"), ("12test", "3t4est", "5te6st")], [[BotCommand(command="Test", description="Test1")], ("test",)], [[BotCommand(command="tEsT", description="Test2")], ("test",)], + [(re.compile(r"test(\d+)"), 'TeSt'), (re.compile(r"test(\d+)"), "test")], ], ) def test_init_casefold(self, commands, checklist):