Aniketsy commented on code in PR #2593:
URL: https://github.com/apache/iceberg-python/pull/2593#discussion_r2449345723


##########
pyiceberg/expressions/__init__.py:
##########
@@ -341,21 +343,27 @@ def __getnewargs__(self) -> Tuple[BooleanExpression, 
BooleanExpression]:
         return (self.left, self.right)
 
 
-class Not(BooleanExpression):
+class Not(IcebergBaseModel, BooleanExpression):
     """NOT operation expression - logical negation."""
 
     child: BooleanExpression
 
-    def __new__(cls, child: BooleanExpression) -> BooleanExpression:  # type: 
ignore
+    @model_validator(mode="before")
+    def _before(cls, values: Any) -> Any:
+        if isinstance(values, BooleanExpression):
+            return {"child": values}
+        return values
+
+    @model_validator(mode="after")
+    def _normalize(cls, model: Any) -> Any:
+        child = model.child
         if child is AlwaysTrue():
             return AlwaysFalse()
         elif child is AlwaysFalse():
             return AlwaysTrue()
         elif isinstance(child, Not):
             return child.child
-        obj = super().__new__(cls)
-        obj.child = child
-        return obj
+        return model

Review Comment:
   sure, i'll update and test it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to