diff --git a/aiogram/contrib/middlewares/logging.py b/aiogram/contrib/middlewares/logging.py index 11265561..fb7600fa 100644 --- a/aiogram/contrib/middlewares/logging.py +++ b/aiogram/contrib/middlewares/logging.py @@ -16,7 +16,8 @@ class LoggingMiddleware(BaseMiddleware): super(LoggingMiddleware, self).__init__() - def check_timeout(self, obj): + @staticmethod + def check_timeout(obj): start = obj.conf.get('_start', None) if start: del obj.conf['_start'] @@ -248,7 +249,8 @@ class LoggingFilter(logging.Filter): yield 'update_type', 'pre_checkout_query' yield from self.process_pre_checkout_query(update.pre_checkout_query) - def make_prefix(self, prefix, iterable): + @staticmethod + def make_prefix(prefix, iterable): """ Add prefix to the label diff --git a/aiogram/dispatcher/filters/builtin.py b/aiogram/dispatcher/filters/builtin.py index dee2c058..2a23e8fc 100644 --- a/aiogram/dispatcher/filters/builtin.py +++ b/aiogram/dispatcher/filters/builtin.py @@ -385,7 +385,8 @@ class HashTag(Filter): or self.cashtags and set(cashtags) & set(self.cashtags): return {'hashtags': hashtags, 'cashtags': cashtags} - def _get_tags(self, text, entities): + @staticmethod + def _get_tags(text, entities): hashtags = [] cashtags = [] @@ -529,7 +530,8 @@ class StateFilter(BoundFilter): states.append(item) self.states = states - def get_target(self, obj): + @staticmethod + def get_target(obj): return getattr(getattr(obj, 'chat', None), 'id', None), getattr(getattr(obj, 'from_user', None), 'id', None) async def check(self, obj): diff --git a/aiogram/dispatcher/storage.py b/aiogram/dispatcher/storage.py index da9da2da..f1686cfe 100644 --- a/aiogram/dispatcher/storage.py +++ b/aiogram/dispatcher/storage.py @@ -198,7 +198,8 @@ class BaseStorage: """ await self.reset_state(chat=chat, user=user, with_data=True) - def has_bucket(self): + @staticmethod + def has_bucket(): return False async def get_bucket(self, *, diff --git a/aiogram/dispatcher/webhook.py b/aiogram/dispatcher/webhook.py index e498a265..1d6b053f 100644 --- a/aiogram/dispatcher/webhook.py +++ b/aiogram/dispatcher/webhook.py @@ -218,7 +218,8 @@ class WebhookRequestHandler(web.View): if response is not None: asyncio.ensure_future(response.execute_response(dispatcher.bot), loop=loop) - def get_response(self, results): + @staticmethod + def get_response(results): """ Get response object from results. diff --git a/tests/test_bot/test_api.py b/tests/test_bot/test_api.py index 9fc16087..c1c32c23 100644 --- a/tests/test_bot/test_api.py +++ b/tests/test_bot/test_api.py @@ -23,10 +23,12 @@ def invalid_token_fixture(request): class TestCheckToken: - def test_valid(self): + @staticmethod + def test_valid(): if check_token(VALID_TOKEN) is not True: raise AssertionError - def test_invalid_token(self, invalid_token): + @staticmethod + def test_invalid_token(invalid_token): with pytest.raises(ValidationError): check_token(invalid_token) diff --git a/tests/test_dispatcher/test_filters/test_state.py b/tests/test_dispatcher/test_filters/test_state.py index 5c1ac676..5f18fedf 100644 --- a/tests/test_dispatcher/test_filters/test_state.py +++ b/tests/test_dispatcher/test_filters/test_state.py @@ -2,7 +2,8 @@ from aiogram.dispatcher.filters.state import StatesGroup class TestStatesGroup: - def test_all_childs(self): + @staticmethod + def test_all_childs(): class InnerState1(StatesGroup): pass diff --git a/tests/test_dispatcher/test_handler.py b/tests/test_dispatcher/test_handler.py index c9d5e105..fd6f33f0 100644 --- a/tests/test_dispatcher/test_handler.py +++ b/tests/test_dispatcher/test_handler.py @@ -18,7 +18,8 @@ async def callback3(foo: int, **kwargs): class TestHandlerObj: - def test_init_decorated(self): + @staticmethod + def test_init_decorated(): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): diff --git a/tests/test_utils/test_auth_widget.py b/tests/test_utils/test_auth_widget.py index dcdccf29..e6c0d297 100644 --- a/tests/test_utils/test_auth_widget.py +++ b/tests/test_utils/test_auth_widget.py @@ -30,22 +30,26 @@ class Test_check_token: This case gonna be deleted """ - def test_ok(self, data): + @staticmethod + def test_ok(data): if check_token(data, TOKEN) is not True: raise AssertionError - def test_fail(self, data): + @staticmethod + def test_fail(data): data.pop("username") if check_token(data, TOKEN) is not False: raise AssertionError class Test_check_integrity: - def test_ok(self, data): + @staticmethod + def test_ok(data): if check_integrity(TOKEN, data) is not True: raise AssertionError - def test_fail(self, data): + @staticmethod + def test_fail(data): data.pop("username") if check_integrity(TOKEN, data) is not False: raise AssertionError diff --git a/tests/test_utils/test_helper.py b/tests/test_utils/test_helper.py index 0faf1af5..fc04d47d 100644 --- a/tests/test_utils/test_helper.py +++ b/tests/test_utils/test_helper.py @@ -2,7 +2,8 @@ from aiogram.utils.helper import Item, ListItem, OrderedHelper class TestOrderedHelper: - def test_items_are_ordered(self): + @staticmethod + def test_items_are_ordered(): class Helper(OrderedHelper): A = Item() D = Item() @@ -12,7 +13,8 @@ class TestOrderedHelper: if Helper.all() != ["A", "D", "C", "B"]: raise AssertionError - def test_list_items_are_ordered(self): + @staticmethod + def test_list_items_are_ordered(): class Helper(OrderedHelper): A = ListItem() D = ListItem() diff --git a/tests/test_utils/test_markdown.py b/tests/test_utils/test_markdown.py index c47d8663..62a6fd93 100644 --- a/tests/test_utils/test_markdown.py +++ b/tests/test_utils/test_markdown.py @@ -4,10 +4,12 @@ from aiogram.utils import markdown class TestMarkdownEscape: - def test_equality_sign_is_escaped(self): + @staticmethod + def test_equality_sign_is_escaped(): if markdown.escape_md(r"e = mc2") != r"e \= mc2": raise AssertionError - def test_pre_escaped(self): + @staticmethod + def test_pre_escaped(): if markdown.escape_md(r"hello\.") != r"hello\\\.": raise AssertionError diff --git a/tests/test_utils/test_text_decorations.py b/tests/test_utils/test_text_decorations.py index 34003a1c..8d8d861c 100644 --- a/tests/test_utils/test_text_decorations.py +++ b/tests/test_utils/test_text_decorations.py @@ -3,7 +3,8 @@ from aiogram.utils import text_decorations class TestTextDecorations: - def test_unparse_entities_normal_text(self): + @staticmethod + def test_unparse_entities_normal_text(): if ( text_decorations.markdown_decoration.unparse( "hi i'm bold and italic and still bold", @@ -18,7 +19,8 @@ class TestTextDecorations: ): raise AssertionError - def test_unparse_entities_emoji_text(self): + @staticmethod + def test_unparse_entities_emoji_text(): """ emoji is encoded as two chars in json """