Skip to content

Commit

Permalink
refactor: remove unnecessary try except
Browse files Browse the repository at this point in the history
  • Loading branch information
jyooru committed Oct 18, 2021
1 parent 2f4e0cc commit 4342bdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 5 additions & 8 deletions pywhat/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ def __len__(self):
return len(self._dict)

def __contains__(self, item):
try:
return (
self["MinRarity"] <= item["Rarity"] <= self["MaxRarity"]
and set(item["Tags"]) & self["Tags"]
and not set(item["Tags"]) & self["ExcludeTags"]
)
except KeyError:
return False
return (
self["MinRarity"] <= item["Rarity"] <= self["MaxRarity"]
and set(item["Tags"]) & self["Tags"]
and not set(item["Tags"]) & self["ExcludeTags"]
)

def setdefault(self, key, default=None):
return self._dict.setdefault(key, default)
Expand Down
5 changes: 0 additions & 5 deletions tests/test_filtration.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,3 @@ def test_filter3():
and "Identifiers" not in regex["Tags"]
):
assert regex in dist.get_regexes()


def test_invalid_contains_returns_false():
filter = Filter()
assert ({} in filter) is False

0 comments on commit 4342bdc

Please sign in to comment.