From 945e1cf8656fd7a13cbc844091f724f0f49fde1b Mon Sep 17 00:00:00 2001 From: RootShinobi <111008396+RootShinobi@users.noreply.github.com> Date: Sat, 4 Nov 2023 20:24:16 +0200 Subject: [PATCH] changes and Sets --- CHANGES/1357.misc.rst | 1 + aiogram/dispatcher/event/handler.py | 4 ++-- tests/test_dispatcher/test_event/test_handler.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 CHANGES/1357.misc.rst diff --git a/CHANGES/1357.misc.rst b/CHANGES/1357.misc.rst new file mode 100644 index 00000000..0f268f7a --- /dev/null +++ b/CHANGES/1357.misc.rst @@ -0,0 +1 @@ +new improved CallableMixin diff --git a/aiogram/dispatcher/event/handler.py b/aiogram/dispatcher/event/handler.py index f20c986b..8afeb182 100644 --- a/aiogram/dispatcher/event/handler.py +++ b/aiogram/dispatcher/event/handler.py @@ -4,7 +4,7 @@ import inspect import warnings from dataclasses import dataclass, field from functools import partial -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Optional, Tuple, Set from magic_filter.magic import MagicFilter as OriginalMagicFilter @@ -21,7 +21,7 @@ CallbackType = Callable[..., Any] class CallableMixin: callback: CallbackType awaitable: bool = field(init=False) - params: set[str] = field(init=False) + params: Set[str] = field(init=False) varkw: bool = field(init=False) def __post_init__(self) -> None: diff --git a/tests/test_dispatcher/test_event/test_handler.py b/tests/test_dispatcher/test_event/test_handler.py index 0c59aff4..b9368a3b 100644 --- a/tests/test_dispatcher/test_event/test_handler.py +++ b/tests/test_dispatcher/test_event/test_handler.py @@ -1,5 +1,5 @@ import functools -from typing import Any, Dict, Union, Callable +from typing import Any, Dict, Union, Callable, Set import pytest from magic_filter import F as A @@ -61,7 +61,7 @@ class TestCallableMixin: pytest.param(SyncCallable(), {"self", "foo", "bar", "baz"}), ], ) - def test_init_args_spec(self, callback: Callable, args: set[str]): + def test_init_args_spec(self, callback: Callable, args: Set[str]): obj = CallableMixin(callback) assert set(obj.params) == args