bito-code-review[bot] commented on code in PR #40475:
URL: https://github.com/apache/superset/pull/40475#discussion_r3335875228
##########
superset-core/src/superset_core/semantic_layers/types.py:
##########
@@ -158,7 +158,7 @@ class Filter:
type: PredicateType
column: Dimension | Metric | None
operator: Operator
- value: FilterValues | frozenset[FilterValues]
+ value: FilterValues | tuple[FilterValues, ...] | frozenset[FilterValues]
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Heterogeneous order comparison crash</b></div>
<div id="fix">
The `order=True` decorator generates `__lt__`/`__gt__` etc. comparing fields
left-to-right. When `value` is a `tuple` in one `Filter` and a `frozenset` in
another (both valid per the new union), Python raises `TypeError: '<' not
supported between instances of 'tuple' and 'frozenset'` at runtime. This
surfaces when `set[Filter]` is iterated or sorted. Either remove `order=True`
or split into separate homogeneous dataclasses for each collection type.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- a/superset-core/src/superset_core/semantic_layers/types.py
+++ b/superset-core/src/superset_core/semantic_layers/types.py
@@ -153,7 +153,7 @@ class PredicateType(enum.Enum):
HAVING = "HAVING"
-@dataclass(frozen=True, order=True)
+@dataclass(frozen=True)
class Filter:
type: PredicateType
column: Dimension | Metric | None
```
</div>
</details>
</div>
<small><i>Code Review Run #15656f</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]