Skip to content

Commit d0351da

Browse files
committed
modernize with pyugprade
1 parent 614b866 commit d0351da

File tree

8 files changed

+13
-17
lines changed

8 files changed

+13
-17
lines changed

dedupe/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def blocks(self, data):
867867
con.execute("ROLLBACK")
868868
con.close()
869869

870-
def score(self, blocks: Blocks) -> Generator[Scores, None, None]:
870+
def score(self, blocks: Blocks) -> Generator[Scores]:
871871
"""
872872
Scores groups of pairs of records. Yields structured numpy arrays
873873
representing pairs of records in the group and the associated

dedupe/blocking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, predicates: Iterable[dedupe.predicates.Predicate]) -> None:
5757

5858
def __call__(
5959
self, records: Iterable[Record], target: bool = False
60-
) -> Generator[tuple[str, RecordID], None, None]:
60+
) -> Generator[tuple[str, RecordID]]:
6161
"""
6262
Generate the predicates for records. Yields tuples of (predicate,
6363
record_id).

dedupe/clustering.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
logger = logging.getLogger(__name__)
1818

1919

20-
def connected_components(
21-
edgelist: Scores, max_components: int
22-
) -> Generator[Scores, None, None]:
20+
def connected_components(edgelist: Scores, max_components: int) -> Generator[Scores]:
2321
if len(edgelist) == 0:
2422
raise StopIteration()
2523

@@ -51,9 +49,7 @@ def connected_components(
5149
edgelist._mmap.close() # type: ignore
5250

5351

54-
def _connected_components(
55-
edgelist: Scores, max_components: int
56-
) -> Generator[Scores, None, None]:
52+
def _connected_components(edgelist: Scores, max_components: int) -> Generator[Scores]:
5753
component_stops = union_find(edgelist)
5854

5955
start = 0

dedupe/convenience.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def console_label(deduper: dedupe.api.ActiveMatching) -> None: # pragma: no cov
161161

162162
for record in record_pair:
163163
for field in fields:
164-
line = "{} : {}".format(field, record[field])
164+
line = f"{field} : {record[field]}"
165165
_print(line)
166166
_print()
167167
_print(f"{n_match}/10 positive, {n_distinct}/10 negative")

dedupe/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def scoreGazette(
218218
featurizer: FeaturizerFunction,
219219
classifier: Classifier,
220220
num_cores: int = 1,
221-
) -> Generator[Scores, None, None]:
221+
) -> Generator[Scores]:
222222
first, record_pairs = peek(record_pairs)
223223
if first is None:
224224
return # terminate iteration

dedupe/datamodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __len__(self) -> int:
8686
@property
8787
def _field_comparators(
8888
self,
89-
) -> Generator[tuple[str, Comparator, int, int], None, None]:
89+
) -> Generator[tuple[str, Comparator, int, int]]:
9090
start = 0
9191
stop = 0
9292
for var in self.field_variables:

dedupe/predicates.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __iter__(self):
5050
yield self
5151

5252
def __repr__(self) -> str:
53-
return "{}: {}".format(self.type, self.__name__)
53+
return f"{self.type}: {self.__name__}"
5454

5555
def __hash__(self) -> int:
5656
try:
@@ -83,7 +83,7 @@ class SimplePredicate(Predicate):
8383

8484
def __init__(self, func: PredicateFunction, field: str):
8585
self.func = func
86-
self.__name__ = "({}, {})".format(func.__name__, field)
86+
self.__name__ = f"({func.__name__}, {field})"
8787
self.field = field
8888

8989
def __call__(self, record: RecordDict, **kwargs) -> frozenset[str]:
@@ -107,7 +107,7 @@ class ExistsPredicate(Predicate):
107107
type = "ExistsPredicate"
108108

109109
def __init__(self, field: str):
110-
self.__name__ = "(Exists, {})".format(field)
110+
self.__name__ = f"(Exists, {field})"
111111
self.field = field
112112

113113
@staticmethod
@@ -129,7 +129,7 @@ class IndexPredicate(Predicate):
129129
_cache: dict[Any, frozenset[str]]
130130

131131
def __init__(self, threshold: float, field: str):
132-
self.__name__ = "({}, {})".format(threshold, field)
132+
self.__name__ = f"({threshold}, {field})"
133133
self.field = field
134134
self.threshold = threshold
135135
self.index = None

dedupe/variables/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DerivedType(Variable):
4444
type = "Derived"
4545

4646
def __init__(self, name: str, var_type: str, **kwargs):
47-
self.name = "({}: {})".format(str(name), str(var_type))
47+
self.name = f"({str(name)}: {str(var_type)})"
4848
super().__init__(**kwargs)
4949

5050

@@ -59,7 +59,7 @@ def __init__(self, field: str, name: str | None = None, has_missing: bool = Fals
5959
self.field = field
6060

6161
if name is None:
62-
self.name = "({}: {})".format(self.field, self.type)
62+
self.name = f"({self.field}: {self.type})"
6363
else:
6464
self.name = name
6565

0 commit comments

Comments
 (0)