Skip to content

Commit

Permalink
Fixed in/contains operations when this action is impossible (for e. g…
Browse files Browse the repository at this point in the history
…. TypeError caused)
  • Loading branch information
JrooTJunior committed Sep 19, 2021
1 parent 67f5d5a commit 3735a6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions magic_filter/operations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ class ImportantFunctionOperation(FunctionOperation):


def in_op(a: Any, b: Any) -> bool:
return b in a
try:
return b in a
except TypeError:
return False


def contains_op(a: Any, b: Any) -> bool:
return a in b
try:
return a in b
except TypeError:
return False
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "magic-filter"
version = "1.0.1"
version = "1.0.2"
description = "This package provides magic filter based on dynamic attribute getter"
license = "MIT"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class TestMagicFilter:
F.about[6:9] == "fly",
F.about[...].islower(),
~F.about[:].isdigit(),
~F.job.contains("test"),
],
)
def test_operations(self, case: MagicFilter, user: User):
Expand Down

0 comments on commit 3735a6b

Please sign in to comment.