Skip to content

Commit

Permalink
ilo MemberFilter li taso lon poki Or la o pana sin e ilo MemberFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
gregdan3 committed Jul 3, 2024
1 parent afc6b9f commit f0706c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sonatoki/Filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ def __new__(cls, *filters: Type[Filter]) -> Type[Filter]:
else:
other_filters.extend(member_filters)

if len(other_filters) == 1: # we only had member filters
# TODO: this sucks?
return other_filters[0]

filter = cls.__generic_filter(*other_filters)
return filter

Expand Down
3 changes: 3 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Punctuation,
AlphabeticRe,
LongSyllabic,
MemberFilter,
NimiLinkuCore,
PunctuationRe,
LongAlphabetic,
Expand Down Expand Up @@ -207,6 +208,8 @@ def test_OrFilter(s: str):
@given(st.sampled_from(list(NIMI_PU | NIMI_LINKU_OBSCURE)))
def test_MemberFilters_OrFilter(s: str):
filter = Or(NimiPu, NimiLinkuObscure)
assert issubclass(filter, MemberFilter)

res = filter.filter(s)
res_pu = NimiPu.filter(s)
res_obscure = NimiLinkuObscure.filter(s)
Expand Down

0 comments on commit f0706c6

Please sign in to comment.