Use basedpyright refactor
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import dataclasses
|
||||
from collections.abc import Iterable
|
||||
from typing import Self
|
||||
|
||||
NGrams = dict[int, list[str]]
|
||||
|
||||
|
||||
@dataclasses.dataclass(order=True)
|
||||
@@ -7,13 +11,14 @@ class SearchMatch:
|
||||
ngram: str
|
||||
|
||||
@classmethod
|
||||
def combine_matches(cls, matches):
|
||||
def combine_matches(cls, matches: Iterable[Self]) -> Self:
|
||||
ngrams, distances = zip(*((match.ngram, match.distance) for match in matches))
|
||||
return cls(
|
||||
ngram=', '.join(ngrams),
|
||||
distance=sum(distances)/len(distances)
|
||||
distance=sum(distances)/len(distances)
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class QueryResult:
|
||||
id: int
|
||||
|
||||
Reference in New Issue
Block a user