Skip to content

Commit

Permalink
update black
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Jun 20, 2024
1 parent 2a3bbfb commit f9ee163
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.12.0
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pycqa/isort
Expand Down
12 changes: 4 additions & 8 deletions dedupe/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,17 @@ class TrainingData(TypedDict):
class Classifier(Protocol):
"""Takes an array of pairwise distances and computes the likelihood they are a pair."""

def fit(self, X: numpy.typing.NDArray[numpy.float64], y: LabelsLike) -> None:
...
def fit(self, X: numpy.typing.NDArray[numpy.float64], y: LabelsLike) -> None: ...

def predict_proba(
self, X: numpy.typing.NDArray[numpy.float64]
) -> numpy.typing.NDArray[numpy.float64]:
...
) -> numpy.typing.NDArray[numpy.float64]: ...


class ClosableJoinable(Protocol):
def close(self) -> None:
...
def close(self) -> None: ...

def join(self) -> None:
...
def join(self) -> None: ...


MapLike = Callable[[Callable[[Any], Any], Iterable], Iterable]
Expand Down
28 changes: 12 additions & 16 deletions dedupe/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,15 @@ def partition(self, data, threshold=0.5): # pragma: no cover

@overload
@staticmethod
def _add_singletons(all_ids: Iterable[int], clusters: ClustersInt) -> ClustersInt:
...
def _add_singletons(
all_ids: Iterable[int], clusters: ClustersInt
) -> ClustersInt: ...

@overload
@staticmethod
def _add_singletons(all_ids: Iterable[str], clusters: ClustersStr) -> ClustersStr:
...
def _add_singletons(
all_ids: Iterable[str], clusters: ClustersStr
) -> ClustersStr: ...

@staticmethod
def _add_singletons(all_ids, clusters):
Expand Down Expand Up @@ -694,12 +696,10 @@ def __del__(self) -> None:
self._close()

@overload
def index(self, data: DataInt) -> None:
...
def index(self, data: DataInt) -> None: ...

@overload
def index(self, data: DataStr) -> None:
...
def index(self, data: DataStr) -> None: ...

def index(self, data): # pragma: no cover
"""
Expand Down Expand Up @@ -786,12 +786,10 @@ def unindex(self, data): # pragma: no cover
del self.indexed_data[k]

@overload
def blocks(self, data: DataInt) -> BlocksInt:
...
def blocks(self, data: DataInt) -> BlocksInt: ...

@overload
def blocks(self, data: DataStr) -> BlocksStr:
...
def blocks(self, data: DataStr) -> BlocksStr: ...

def blocks(self, data):
"""
Expand Down Expand Up @@ -1009,14 +1007,12 @@ def search(
@overload
def _format_search_results(
self, search_d: DataInt, results: ArrayLinks
) -> LookupResultsInt:
...
) -> LookupResultsInt: ...

@overload
def _format_search_results(
self, search_d: DataStr, results: ArrayLinks
) -> LookupResultsStr:
...
) -> LookupResultsStr: ...

def _format_search_results(self, search_d, results):
seen: set[RecordID] = set()
Expand Down
6 changes: 2 additions & 4 deletions dedupe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,11 @@ def Enumerator(start: int = 0) -> collections.defaultdict[Any, int]:


@overload
def sniff_id_type(ids: Sequence[tuple[int, int]]) -> Type[int]:
...
def sniff_id_type(ids: Sequence[tuple[int, int]]) -> Type[int]: ...


@overload
def sniff_id_type(ids: Sequence[tuple[str, str]]) -> tuple[Type[str], Literal[256]]:
...
def sniff_id_type(ids: Sequence[tuple[str, str]]) -> tuple[Type[str], Literal[256]]: ...


def sniff_id_type(ids: Sequence[tuple[RecordID, RecordID]]) -> RecordIDDType:
Expand Down
12 changes: 4 additions & 8 deletions dedupe/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,10 @@ def _index_predicates(self, candidates: TrainingExamples) -> None:
pred.freeze(records)

@overload
def _sample(self, data: DataInt, sample_size: int) -> TrainingExamples:
...
def _sample(self, data: DataInt, sample_size: int) -> TrainingExamples: ...

@overload
def _sample(self, data: DataStr, sample_size: int) -> TrainingExamples:
...
def _sample(self, data: DataStr, sample_size: int) -> TrainingExamples: ...

def _sample(self, data, sample_size):
sample_indices = self._sample_indices(
Expand Down Expand Up @@ -323,14 +321,12 @@ def _index_predicates(self, candidates: TrainingExamples) -> None:
@overload
def _sample(
self, data_1: DataInt, data_2: DataInt, sample_size: int
) -> TrainingExamples:
...
) -> TrainingExamples: ...

@overload
def _sample(
self, data_1: DataStr, data_2: DataStr, sample_size: int
) -> TrainingExamples:
...
) -> TrainingExamples: ...

def _sample(self, data_1, data_2, sample_size):
sample_indices = self._sample_indices(sample_size, len(data_1) * len(data_2))
Expand Down
9 changes: 3 additions & 6 deletions dedupe/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,16 @@ def __setstate__(self, d: Mapping[str, Any]) -> None:
self.index = None

@abc.abstractmethod
def reset(self) -> None:
...
def reset(self) -> None: ...

@abc.abstractmethod
def initIndex(self) -> Index:
...
def initIndex(self) -> Index: ...

def bust_cache(self) -> None:
self._cache = {}

@abc.abstractmethod
def preprocess(self, doc: Any) -> Any:
...
def preprocess(self, doc: Any) -> Any: ...


class CanopyPredicate(IndexPredicate):
Expand Down
18 changes: 6 additions & 12 deletions dedupe/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,13 @@ def __init__(
@staticmethod
def coveredPairs(
blocker: blocking.Fingerprinter, records: DataInt
) -> ComparisonCoverInt:
...
) -> ComparisonCoverInt: ...

@overload
@staticmethod
def coveredPairs(
blocker: blocking.Fingerprinter, records: DataStr
) -> ComparisonCoverStr:
...
) -> ComparisonCoverStr: ...

@staticmethod
def coveredPairs(blocker: blocking.Fingerprinter, records):
Expand Down Expand Up @@ -251,8 +249,7 @@ def __init__(
sampled_records_1: DataInt,
sampled_records_2: DataInt,
data_2: DataInt,
):
...
): ...

@overload
def __init__(
Expand All @@ -261,8 +258,7 @@ def __init__(
sampled_records_1: DataStr,
sampled_records_2: DataStr,
data_2: DataStr,
):
...
): ...

def __init__(
self,
Expand All @@ -281,14 +277,12 @@ def __init__(
@overload
def coveredPairs(
self, blocker: blocking.Fingerprinter, records_1: DataInt, records_2: DataInt
) -> ComparisonCoverInt:
...
) -> ComparisonCoverInt: ...

@overload
def coveredPairs(
self, blocker: blocking.Fingerprinter, records_1: DataStr, records_2: DataStr
) -> ComparisonCoverStr:
...
) -> ComparisonCoverStr: ...

def coveredPairs(self, blocker, records_1, records_2):
cover: dict[Predicate, dict[str, tuple[set[RecordID], set[RecordID]]]] = {}
Expand Down

0 comments on commit f9ee163

Please sign in to comment.