diff --git a/src/celpy/celtypes.py b/src/celpy/celtypes.py index 8f6bf8f..71115e3 100644 --- a/src/celpy/celtypes.py +++ b/src/celpy/celtypes.py @@ -442,6 +442,9 @@ def __new__( def __repr__(self) -> str: return f"{self.__class__.__name__}({super().__repr__()})" + def contains(self, item: Value) -> BoolType: + return BoolType(cast(BytesType, item) in self) + class DoubleType(float): """ diff --git a/tests/test_celtypes.py b/tests/test_celtypes.py index f8cdd68..c0067f1 100644 --- a/tests/test_celtypes.py +++ b/tests/test_celtypes.py @@ -81,6 +81,7 @@ def test_bytes_type(): assert repr(b_0) == "BytesType(b'bytes')" assert BytesType(None) == BytesType(b'') assert BytesType(MessageType({"value": BytesType(b'42')})) == BytesType(b'42') + assert b_0.contains(b'byte') def test_double_type():