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