Skip to content
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
2 changes: 1 addition & 1 deletion temporalio/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def __contains__(self, key: object) -> bool:

This uses key equality so the key must be the same name and type.
"""
return any(v for k, v in self if k == key)
return any(k == key for k, v in self)

@overload
def get(
Expand Down
19 changes: 19 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ def test_typed_search_attribute_duplicates():
)


def test_typed_search_attributes_contains_with_falsy_value():
int_key = SearchAttributeKey.for_int("my-int")
attrs = TypedSearchAttributes([SearchAttributePair(int_key, 0)])
assert int_key in attrs


def test_typed_search_attributes_contains_with_truthy_value():
int_key = SearchAttributeKey.for_int("my-int")
attrs = TypedSearchAttributes([SearchAttributePair(int_key, 42)])
assert int_key in attrs


def test_typed_search_attributes_contains_missing_key():
int_key = SearchAttributeKey.for_int("my-int")
missing_key = SearchAttributeKey.for_keyword("missing")
attrs = TypedSearchAttributes([SearchAttributePair(int_key, 42)])
assert missing_key not in attrs


def test_cant_construct_bad_priority():
with pytest.raises(TypeError):
Priority(priority_key=1.1) # type: ignore
Expand Down