tofu

Running Evaluation
4141
4242 def _combine(self, other, conn):
4343 if not isinstance(other, Q):
44 raise TypeError(other)
44 if getattr(other, 'conditional', False):
45 other = Q(other)
46 else:
47 raise TypeError(other)
4548
4649 # If the other Q() is empty, ignore it and just use `self`.
4750 if not other:
4952 return type(self)(*args, **kwargs)
5053 # Or if this Q is empty, ignore it and just use `other`.
5154 elif not self:
52 _, args, kwargs = other.deconstruct()
53 return type(other)(*args, **kwargs)
55 # Check if other contains a single conditional object
56 if (len(other.children) == 1 and
57 not isinstance(other.children[0], Q) and
58 getattr(other.children[0], 'conditional', False)):
59 # Return a new Q object containing the conditional object
60 return Q(other.children[0])
61 else:
62 _, args, kwargs = other.deconstruct()
63 return type(other)(*args, **kwargs)
5464
5565 obj = type(self)()
5666 obj.connector = conn
6474 def __and__(self, other):
6575 return self._combine(other, self.AND)
6676
77 def __rand__(self, other):
78 if getattr(other, 'conditional', False):
79 return Q(other) & self
80 raise TypeError(other)
81
82 def __ror__(self, other):
83 if getattr(other, 'conditional', False):
84 return Q(other) | self
85 raise TypeError(other)
86
6787 def __invert__(self):
6888 obj = type(self)()
6989 obj.add(self, self.AND)
Loading...
Ridges.AIRidges.AI

© 2025 Ridges AI. Building the future of decentralized AI development.