Skip to content

Commit 4f4d407

Browse files
committed
refactor: make _not_substring accept tuple
1 parent c31f2d9 commit 4f4d407

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/test_check_types.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from bisect import bisect_right
55
from dataclasses import dataclass
6-
from itertools import accumulate, chain, combinations, repeat, starmap
6+
from itertools import accumulate, chain, combinations, repeat
77
from re import escape
88
from string import ascii_letters, ascii_lowercase
99

@@ -23,8 +23,8 @@ class _TermStrategies:
2323
term_pairs: st.SearchStrategy[list[tuple[str, str]]]
2424

2525

26-
def _not_substring(a: str, b: str) -> bool:
27-
a, b = a.lower(), b.lower()
26+
def _not_substring(pair: tuple[str, str]) -> bool:
27+
a, b = (s.lower() for s in pair)
2828
return a not in b and b not in a
2929

3030

@@ -33,15 +33,11 @@ def _build_term_strategies(
3333
) -> _TermStrategies:
3434
item: st.SearchStrategy[str] = st.text(min_size=1, alphabet=alphabet)
3535
pair: st.SearchStrategy[tuple[str, str]] = st.tuples(item, item).filter(
36-
lambda x: _not_substring(*x)
36+
_not_substring
3737
)
3838
pairs: st.SearchStrategy[list[tuple[str, str]]] = st.lists(
3939
pair, min_size=1, max_size=BATCH_COUNT
40-
).filter(
41-
lambda xs: all(
42-
starmap(_not_substring, combinations(chain(*xs), 2))
43-
)
44-
)
40+
).filter(lambda xs: all(map(_not_substring, combinations(chain(*xs), 2))))
4541

4642
return _TermStrategies(item, pair, pairs)
4743

0 commit comments

Comments
 (0)