diff --git a/sopel/plugins/rules.py b/sopel/plugins/rules.py index a38da75dd..a40b41ae6 100644 --- a/sopel/plugins/rules.py +++ b/sopel/plugins/rules.py @@ -1760,7 +1760,6 @@ class URLCallback(Rule): @classmethod def from_callable(cls, settings, handler): - execute_handler = handler regexes = cls.regex_from_callable(settings, handler) kwargs = cls.kwargs_from_callable(handler) @@ -1772,13 +1771,19 @@ def from_callable(cls, settings, handler): # account for the 'self' parameter when the handler is a method match_count = 4 + execute_handler = handler argspec = inspect.getfullargspec(handler) if len(argspec.args) >= match_count: @functools.wraps(handler) - def execute_handler(bot, trigger): + def handler_match_wrapper(bot, trigger): return handler(bot, trigger, match=trigger) + # don't directly `def execute_handler` to override it; + # doing incurs the wrath of pyflakes in the form of + # "F811: Redefinition of unused name" + execute_handler = handler_match_wrapper + kwargs.update({ 'handler': execute_handler, 'schemes': settings.core.auto_url_schemes,