Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement InsensitiveSet.__contains__ #1197

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 95.2.0

* Implement `InsensitiveSet.__contains__`

## 95.1.2

* Fix to the number of arguments the `on_retry` of the `NotifyTask` class takes.
Expand Down
3 changes: 3 additions & 0 deletions notifications_utils/insensitive_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ def make_key(original_key):
class InsensitiveSet(OrderedSet):
def __init__(self, iterable):
return super().__init__(InsensitiveDict.from_keys(iterable).values())

def __contains__(self, key):
return key in InsensitiveDict.from_keys(self)
2 changes: 1 addition & 1 deletion notifications_utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# - `make version-minor` for new features
# - `make version-patch` for bug fixes

__version__ = "95.1.2" # a47171c8774fee6d72573d446710b651
__version__ = "95.2.0" # e423953f9dec74010897c62aa4e035de
21 changes: 21 additions & 0 deletions tests/test_insensitive_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,27 @@ def test_insensitive_set():
)


def test_insensitive_set_contains():
foobar = InsensitiveSet(("foo", "bar"))

for key in (
"foo",
"F o o ",
"F_O_O",
"B_A_R",
"B a r",
"bar",
):
assert key in foobar

for key in (
"baz",
"barz",
"z foo",
):
assert key not in foobar


@pytest.mark.parametrize(
"extra_args, expected_dict",
(
Expand Down