Make some dependency changes, support Python 3.10 and 3.11 (#5611)

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Jakub Kuczys
2022-12-30 03:21:57 +01:00
committed by GitHub
parent d3308af0e2
commit 519acedf46
59 changed files with 324 additions and 373 deletions

View File

@@ -32,7 +32,7 @@ from typing import (
import aiohttp
import discord
from packaging.requirements import Requirement
from fuzzywuzzy import fuzz, process
from rapidfuzz import fuzz, process
from rich.progress import ProgressColumn
from rich.progress_bar import ProgressBar
from red_commons.logging import VERBOSE, TRACE
@@ -147,20 +147,20 @@ async def fuzzy_command_search(
return None
if commands is None:
choices = set(ctx.bot.walk_commands())
choices = {c: c.qualified_name for c in ctx.bot.walk_commands()}
elif isinstance(commands, collections.abc.AsyncIterator):
choices = {c async for c in commands}
choices = {c: c.qualified_name async for c in commands}
else:
choices = set(commands)
choices = {c: c.qualified_name for c in commands}
# Do the scoring. `extracted` is a list of tuples in the form `(command, score)`
# Do the scoring. `extracted` is a list of tuples in the form `(cmd_name, score, cmd)`
extracted = process.extract(term, choices, limit=5, scorer=fuzz.QRatio)
if not extracted:
return None
# Filter through the fuzzy-matched commands.
matched_commands = []
for command, score in extracted:
for __, score, command in extracted:
if score < min_score:
# Since the list is in decreasing order of score, we can exit early.
break