diff --git a/plugins/Autocomplete/plugin.py b/plugins/Autocomplete/plugin.py index fee90457f..31cbcf8da 100644 --- a/plugins/Autocomplete/plugin.py +++ b/plugins/Autocomplete/plugin.py @@ -56,7 +56,9 @@ def _commonPrefix(L): def _getAutocompleteResponse(irc, msg, payload): """Returns the value of the +draft/autocomplete-response tag for the given +draft/autocomplete-request payload.""" - tokens = callbacks.tokenize(payload, channel=msg.channel, network=irc.network) + tokens = callbacks.tokenize( + payload, channel=msg.channel, network=irc.network + ) normalized_payload = " ".join(tokens) candidate_commands = _getCandidates(irc, normalized_payload) @@ -81,12 +83,16 @@ def _getAutocompleteResponse(irc, msg, payload): candidate[len(common_prefix)] for candidate in tokenized_candidates } - commands = [" ".join(common_prefix + [word]) for word in words_after_prefix] + commands = [ + " ".join(common_prefix + [word]) for word in words_after_prefix + ] # strip what the user already typed assert all(command.startswith(normalized_payload) for command in commands) normalized_payload_length = len(normalized_payload) - response_items = [command[normalized_payload_length:] for command in commands] + response_items = [ + command[normalized_payload_length:] for command in commands + ] return "\t".join(sorted(response_items)) @@ -103,7 +109,9 @@ def _getCandidates(irc, normalized_payload): cb_commands += [plugin_name + " " + command for command in cb_commands] candidates |= { - command for command in cb_commands if command.startswith(normalized_payload) + command + for command in cb_commands + if command.startswith(normalized_payload) } return candidates diff --git a/plugins/Autocomplete/test.py b/plugins/Autocomplete/test.py index bb42ff9d0..50796a07d 100644 --- a/plugins/Autocomplete/test.py +++ b/plugins/Autocomplete/test.py @@ -41,7 +41,10 @@ class AutocompleteTestCase(PluginTestCase): self.irc.feedMsg( ircmsgs.IrcMsg( prefix="foo!bar@baz", - server_tags={"msgid": "1234", "+draft/autocomplete-request": request}, + server_tags={ + "msgid": "1234", + "+draft/autocomplete-request": request, + }, command="TAGMSG", args=[self.nick], ) @@ -86,7 +89,9 @@ class AutocompleteTestCase(PluginTestCase): with conf.supybot.protocols.irc.experimentalExtensions.context(True): with conf.supybot.plugins.Autocomplete.enabled.context(True): self._assertAutocompleteResponse("misc t", "ell") - self._assertAutocompleteResponse("misc c", "learmores\tompletenick") + self._assertAutocompleteResponse( + "misc c", "learmores\tompletenick" + ) def testSinglePluginName(self): with conf.supybot.protocols.irc.experimentalExtensions.context(True): @@ -119,7 +124,10 @@ class AutocompleteChannelTestCase(ChannelPluginTestCase): self.irc.feedMsg( ircmsgs.IrcMsg( prefix="foo!bar@baz", - server_tags={"msgid": "1234", "+draft/autocomplete-request": request}, + server_tags={ + "msgid": "1234", + "+draft/autocomplete-request": request, + }, command="TAGMSG", args=[self.channel], ) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..599bce622 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.black] +line-length = 79 + +include = 'plugins/(Autocomplete|Fediverse)/.*\.pyi?$'