Skip to content

Commit 5617a47

Browse files
feat: add function __contains__ in DataModel class
1 parent 57aad36 commit 5617a47

File tree

1 file changed

+13
-0
lines changed
  • synalinks/src/backend/pydantic

1 file changed

+13
-0
lines changed

synalinks/src/backend/pydantic/core.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,19 @@ def __rxor__(self, other):
562562
ops.Xor()(other, self),
563563
)
564564

565+
def __contains__(cls, other):
566+
"""Check if the schema of `other` is contained in this one.
567+
568+
Args:
569+
other (SymbolicDataModel | DataModel): The other data model to compare with.
570+
571+
Returns:
572+
(bool): True if all properties of `other` are present in this one.
573+
"""
574+
from synalinks.src.backend.common.json_schema_utils import contains_schema
575+
576+
return contains_schema(cls.get_schema(), other.get_schema())
577+
565578
def get_config(self):
566579
return self.get_json()
567580

0 commit comments

Comments
 (0)