@@ -299,10 +299,6 @@ class And(BooleanExpression):
299299 left : BooleanExpression
300300 right : BooleanExpression
301301
302- def __init__ (self , left : BooleanExpression , right : BooleanExpression , * rest : BooleanExpression ) -> None :
303- if isinstance (self , And ):
304- super ().__init__ (left = left , right = right )
305-
306302 def __new__ (cls , left : BooleanExpression , right : BooleanExpression , * rest : BooleanExpression ) -> BooleanExpression :
307303 if rest :
308304 return _build_balanced_tree (And , (left , right , * rest ))
@@ -313,8 +309,11 @@ def __new__(cls, left: BooleanExpression, right: BooleanExpression, *rest: Boole
313309 elif right is AlwaysTrue ():
314310 return left
315311 else :
316- obj = super ().__new__ (cls )
317- return obj
312+ return super ().__new__ (cls )
313+
314+ def __init__ (self , left : BooleanExpression , right : BooleanExpression , * rest : BooleanExpression ) -> None :
315+ if isinstance (self , And ) and not hasattr (self , "left" ) and not hasattr (self , "right" ):
316+ super ().__init__ (left = left , right = right )
318317
319318 def __eq__ (self , other : Any ) -> bool :
320319 """Return the equality of two instances of the And class."""
@@ -348,7 +347,7 @@ class Or(BooleanExpression):
348347 right : BooleanExpression
349348
350349 def __init__ (self , left : BooleanExpression , right : BooleanExpression , * rest : BooleanExpression ) -> None :
351- if isinstance (self , Or ):
350+ if isinstance (self , Or ) and not hasattr ( self , "left" ) and not hasattr ( self , "right" ) :
352351 super ().__init__ (left = left , right = right )
353352
354353 def __new__ (cls , left : BooleanExpression , right : BooleanExpression , * rest : BooleanExpression ) -> BooleanExpression :
@@ -361,8 +360,7 @@ def __new__(cls, left: BooleanExpression, right: BooleanExpression, *rest: Boole
361360 elif right is AlwaysFalse ():
362361 return left
363362 else :
364- obj = super ().__new__ (cls )
365- return obj
363+ return super ().__new__ (cls )
366364
367365 def __str__ (self ) -> str :
368366 """Return the string representation of the Or class."""
0 commit comments