Skip to content

Commit c31f2d9

Browse files
committed
fix: lower filters
1 parent 0ce663a commit c31f2d9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_check_types.py

Lines changed: 9 additions & 5 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
6+
from itertools import accumulate, chain, combinations, repeat, starmap
77
from re import escape
88
from string import ascii_letters, ascii_lowercase
99

@@ -23,19 +23,23 @@ 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()
28+
return a not in b and b not in a
29+
30+
2631
def _build_term_strategies(
2732
alphabet: str,
2833
) -> _TermStrategies:
2934
item: st.SearchStrategy[str] = st.text(min_size=1, alphabet=alphabet)
3035
pair: st.SearchStrategy[tuple[str, str]] = st.tuples(item, item).filter(
31-
lambda x: x[0] not in x[1] and x[1] not in x[0]
36+
lambda x: _not_substring(*x)
3237
)
3338
pairs: st.SearchStrategy[list[tuple[str, str]]] = st.lists(
3439
pair, min_size=1, max_size=BATCH_COUNT
3540
).filter(
36-
lambda x: all(
37-
item[0] not in item[1] and item[1] not in item[0]
38-
for item in combinations(chain(*x), 2)
41+
lambda xs: all(
42+
starmap(_not_substring, combinations(chain(*xs), 2))
3943
)
4044
)
4145

0 commit comments

Comments
 (0)