From ddd92acc09067b383ea22bf850326afe0371cf47 Mon Sep 17 00:00:00 2001 From: birdi Date: Mon, 29 Jul 2019 21:59:32 +0300 Subject: [PATCH 1/2] Wrapped function can be registered as handler --- aiogram/dispatcher/handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiogram/dispatcher/handler.py b/aiogram/dispatcher/handler.py index 17b715d1..2a77d580 100644 --- a/aiogram/dispatcher/handler.py +++ b/aiogram/dispatcher/handler.py @@ -23,11 +23,11 @@ class CancelHandler(Exception): def _get_spec(func: callable): + wrapped_function = func while hasattr(func, '__wrapped__'): # Try to resolve decorated callbacks func = func.__wrapped__ - spec = inspect.getfullargspec(func) - return spec, func + return spec, wrapped_function def _check_spec(spec: inspect.FullArgSpec, kwargs: dict): From d2d49282f55544886a38a577d6692c0d7349115c Mon Sep 17 00:00:00 2001 From: birdi Date: Tue, 30 Jul 2019 12:25:42 +0300 Subject: [PATCH 2/2] make handler._get_spec return only specs --- aiogram/dispatcher/handler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aiogram/dispatcher/handler.py b/aiogram/dispatcher/handler.py index 2a77d580..889dc8d6 100644 --- a/aiogram/dispatcher/handler.py +++ b/aiogram/dispatcher/handler.py @@ -23,11 +23,10 @@ class CancelHandler(Exception): def _get_spec(func: callable): - wrapped_function = func while hasattr(func, '__wrapped__'): # Try to resolve decorated callbacks func = func.__wrapped__ spec = inspect.getfullargspec(func) - return spec, wrapped_function + return spec def _check_spec(spec: inspect.FullArgSpec, kwargs: dict): @@ -56,7 +55,7 @@ class Handler: :param filters: list of filters :param index: you can reorder handlers """ - spec, handler = _get_spec(handler) + spec = _get_spec(handler) if filters and not isinstance(filters, (list, tuple, set)): filters = [filters]