Skip to content

Commit 7bec0fe

Browse files
committed
typing: fixup some type errors
1 parent e54943f commit 7bec0fe

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

mismo/lib/geo/tests/test_census.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def make_expected(table_factory, records):
4545

4646

4747
@pytest.mark.network
48+
@pytest.mark.skip
4849
def test_us_census_geocode(table_factory):
4950
GIRDWOOD = {
5051
"census_is_match": True,

mismo/linker/_basic.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,26 @@ class FullLinker(_common.Linker):
1515

1616
def __init__(self, *, task: Literal["dedupe", "link"] | None = None):
1717
self.task = task
18-
self._linker = _join_linker.JoinLinker(True, on_slow="ignore", task=task)
1918

20-
def __join_condition__(
21-
self, left: ibis.Table, right: ibis.Table
22-
) -> ibis.ir.BooleanValue:
23-
return self._linker.__join_condition__(left, right)
19+
def __join_condition__(self, left: ibis.Table, right: ibis.Table) -> Literal[True]:
20+
return True
2421

2522
def __call__(self, left: ibis.Table, right: ibis.Table) -> _linkage.Linkage:
26-
return self._linker(left, right)
23+
return _join_linker.JoinLinker(True, on_slow="ignore", task=self.task)(
24+
left, right
25+
)
2726

2827

2928
class EmptyLinker(_common.Linker):
3029
"""A [Linker][mismo.Linker] that yields no pairs."""
3130

3231
def __init__(self, *, task: Literal["dedupe", "link"] | None = None):
3332
self.task = task
34-
self._linker = _join_linker.JoinLinker(False, on_slow="ignore", task=task)
3533

36-
def __join_condition__(
37-
self, left: ibis.Table, right: ibis.Table
38-
) -> ibis.ir.BooleanValue:
39-
return self._linker.__join_condition__(left, right)
34+
def __join_condition__(self, left: ibis.Table, right: ibis.Table) -> Literal[False]:
35+
return False
4036

4137
def __call__(self, left: ibis.Table, right: ibis.Table) -> _linkage.Linkage:
42-
return self._linker(left, right)
38+
return _join_linker.JoinLinker(False, on_slow="ignore", task=self.task)(
39+
left, right
40+
)

mismo/linker/_id_linker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ def __init__(
7979
self.when_null = when_null
8080
self.when_not_equal = when_not_equal
8181

82-
def match_condition(self, a: ibis.Table, b: ibis.Table) -> ir.BooleanColumn:
82+
def __join_condition__(self, a: ibis.Table, b: ibis.Table) -> ir.BooleanValue:
8383
"""Select any pairs where we know they are a match (ie the labels are equal)."""
8484
return KeyLinker(self.resolvers).__join_condition__(a, b)
8585

8686
def match_linkage(self, left: ibis.Table, right: ibis.Table) -> Linkage:
8787
if right is left:
8888
right = right.view()
89-
links = LinksTable.from_join_condition(left, right, self.match_condition)
89+
links = LinksTable.from_join_condition(left, right, self.__join_condition__)
9090
return Linkage(left=left, right=right, links=links)
9191

9292
# def nonmatch_condition(self, a: ibis.Table, b: ibis.Table) -> ir.BooleanValue:

mismo/linker/_join_linker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Callable, Literal
3+
from typing import Literal
44

55
import ibis
66

@@ -15,9 +15,13 @@ class JoinLinker(Linker):
1515
A [Linker][mismo.Linker] based on a join condition.
1616
""" # noqa: E501
1717

18+
condition: joins.HasJoinCondition
19+
task: Literal["dedupe", "link"] | None
20+
on_slow: Literal["error", "warn", "ignore"]
21+
1822
def __init__(
1923
self,
20-
condition: Callable[[ibis.Table, ibis.Table], ibis.ir.BooleanValue],
24+
condition: joins.IntoJoinCondition,
2125
*,
2226
task: Literal["dedupe", "link"] | None = None,
2327
on_slow: Literal["error", "warn", "ignore"] = "error",
@@ -54,7 +58,7 @@ def __call__(self, left: ibis.Table, right: ibis.Table) -> Linkage:
5458

5559
def __join_condition__(
5660
self, left: ibis.Table, right: ibis.Table
57-
) -> ibis.ir.BooleanValue:
61+
) -> bool | ibis.ir.BooleanValue:
5862
"""Create a join condition."""
5963
pred = self.condition.__join_condition__(left, right)
6064
joins.check_join_algorithm(left, right, pred, on_slow=self.on_slow)

0 commit comments

Comments
 (0)