Skip to content

Commit

Permalink
plugins.rules: fix newly detected case of F811 in pyflakes 3.1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Aug 3, 2023
1 parent 2bcddff commit 314c8a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sopel/plugins/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand Down

0 comments on commit 314c8a2

Please sign in to comment.