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


##########
tests/unit_tests/models/test_time_comparison_offset.py:
##########
@@ -0,0 +1,84 @@
+# 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.
+"""Regression test for #40501.
+
+Time comparisons using a relative offset (e.g. ``'365 days ago'``) on
+coarse time grains (``month`` / ``quarter`` / ``year``) previously
+snapped the compared bucket to the full grain boundary when the current
+period was not fully aligned to the grain. On ``2026-05-01 :
+2026-05-28`` with ``month`` grain, the ``365 days ago`` comparison
+covered all of May 2025 instead of only the first 28 days.
+
+Root cause: ``ExploreMixin.processing_time_offsets`` set
+``inner_from_dttm`` / ``inner_to_dttm`` to the shifted range in the
+relative-offset branch, while the sibling date-range branch left them
+unset. The fix aligns the two branches โ€” both leave inner bounds
+``None`` so the downstream subquery uses one WHERE clause on the
+shifted outer range instead of layering a second, semantically-different
+filter that widened the bucket via the semantic-layer subquery-bounds
+path.
+
+Pinned at the source level because ``processing_time_offsets`` executes
+real datasource queries end-to-end โ€” mocking the full call chain just to
+inspect a local variable inside a ~250-line method would be far more
+fragile than reading the committed source.
+"""
+
+from __future__ import annotations
+
+import inspect
+import re
+
+from superset.models.helpers import ExploreMixin
+
+_SOURCE = inspect.getsource(ExploreMixin.processing_time_offsets)

Review Comment:
   **Suggestion:** Add an explicit type annotation to the module-level 
`_SOURCE` variable to satisfy the requirement that relevant new Python 
variables be typed. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The module-level `_SOURCE` variable is newly introduced and inferred as a 
string from `inspect.getsource(...)`, but it lacks an explicit type annotation. 
This matches the custom rule requiring type hints on relevant Python variables 
that can be annotated.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=b410214800a04d1b86f55f116575be42&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=b410214800a04d1b86f55f116575be42&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/models/test_time_comparison_offset.py
   **Line:** 48:48
   **Comment:**
        *Custom Rule: Add an explicit type annotation to the module-level 
`_SOURCE` variable to satisfy the requirement that relevant new Python 
variables be typed.
   
   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%2F42082&comment_hash=b778ccf03130b3aff9487919e92a72090dc83067a5a8083504f89cb599ce225f&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42082&comment_hash=b778ccf03130b3aff9487919e92a72090dc83067a5a8083504f89cb599ce225f&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