codeant-ai-for-open-source[bot] commented on code in PR #40397:
URL: https://github.com/apache/superset/pull/40397#discussion_r3476453740


##########
tests/unit_tests/daos/test_base_relationship_filters.py:
##########
@@ -0,0 +1,203 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for BaseDAO.apply_column_operators with relationship columns.
+
+`apply_column_operators` historically only worked on scalar columns. When a
+caller asked for `{col: "<m2m_relationship>", opr: "eq", value: <id>}` the
+SQLAlchemy backend raised "Can't compare a collection to an object."
+
+The behavior now: detect the relationship attribute and dispatch to
+`column.any(<related_pk> == value)`, so callers can use the natural shape
+for both scalar columns and m2m relationships.
+"""
+
+from unittest.mock import MagicMock
+
+import pytest
+
+from superset.daos.base import BaseDAO, ColumnOperator, ColumnOperatorEnum
+from superset.models.slice import Slice
+
+
+class _SliceDAO(BaseDAO[Slice]):
+    """Tiny concrete DAO so we can exercise the BaseDAO logic against the
+    real Slice model + its m2m `dashboards` relationship without standing up
+    a full database."""
+
+    model_cls = Slice
+    filterable_relationships = frozenset({"dashboards"})
+
+
+class _SliceDAONoRelationships(BaseDAO[Slice]):
+    """Same model but with no relationships opted into discovery. Used to
+    verify the default behavior (empty ``filterable_relationships``)
+    keeps relationship columns out of the schema-discovery output."""
+
+    model_cls = Slice
+
+
+class TestApplyColumnOperatorsRelationship:
+    """`apply_column_operators` handles m2m relationship columns via .any()."""
+
+    def test_eq_on_relationship_dispatches_to_any(self):

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this new test 
method (for example, `-> None`) to satisfy the full typing requirement for 
newly added Python functions. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test method and it lacks an explicit return 
type annotation. The rule requires new Python functions and methods to be fully 
typed, so this is a real violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f04c004e6b0c47a6bd426a6f9f00239b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f04c004e6b0c47a6bd426a6f9f00239b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/daos/test_base_relationship_filters.py
   **Line:** 57:57
   **Comment:**
        *Custom Rule: Add an explicit return type annotation to this new test 
method (for example, `-> None`) to satisfy the full typing requirement for 
newly added Python functions.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40397&comment_hash=687e045d073d9b894b56faa216c123ee6173f89c9164cbe3f254520e0a1f568a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40397&comment_hash=687e045d073d9b894b56faa216c123ee6173f89c9164cbe3f254520e0a1f568a&reaction=dislike'>👎</a>



-- 
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