Merge pull request #180 from Birdi7/fix-wrapped-func

Wrapped function can be registered as handler
This commit is contained in:
Alex Root Junior 2019-08-04 20:12:41 +03:00 committed by GitHub
commit 7bf704d3de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,9 +25,8 @@ class CancelHandler(Exception):
def _get_spec(func: callable):
while hasattr(func, '__wrapped__'): # Try to resolve decorated callbacks
func = func.__wrapped__
spec = inspect.getfullargspec(func)
return spec, func
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]