bito-code-review[bot] commented on code in PR #44895:
URL: https://github.com/apache/superset/pull/44895#discussion_r4167113166


##########
scripts/change_detector.py:
##########
@@ -217,43 +254,10 @@ def main(event_type: str, sha: str, repo: str) -> None:
             files, patterns_compiled
         )
 
-    # Output results
-    output_path = os.getenv("GITHUB_OUTPUT") or "/tmp/GITHUB_OUTPUT.txt"  # 
noqa: S108
-    with open(output_path, "a") as f:
-        for check, changed in changes_detected.items():
-            # NOTE: as noted above, we assume that if 100 files are touched, 
we should
-            # trigger all checks. This is a workaround for the GitHub API 
limit of 100
-            # files. Using >= 99 because off-by-one errors are not uncommon
-            if changed or (files is not None and len(files) >= 99):
-                print(f"{check}=true", file=f)
-                print(f"Triggering group: {check}")
-
-
-def get_git_sha() -> str:
-    return os.getenv("GITHUB_SHA") or subprocess.check_output(  # noqa: S603
-        ["git", "rev-parse", "HEAD"]  # noqa: S603, S607
-    ).strip().decode("utf-8")
-
-
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(
-        description="Detect file changes based on event context"
-    )
-    parser.add_argument(
-        "--event-type",
-        default=os.getenv("GITHUB_EVENT_NAME") or "push",
-        help="The type of event that triggered the workflow",
-    )
-    parser.add_argument(
-        "--sha",
-        default=get_git_sha(),
-        help="The commit SHA for push events or PR head SHA",
-    )
-    parser.add_argument(
-        "--repo",
-        default=os.getenv("GITHUB_REPOSITORY") or "apache/superset",
-        help="GitHub repository in the format owner/repo",
-    )
-    args = parser.parse_args()
-
-    main(args.event_type, args.sha, args.repo)
+    # The 100-file API cap below treats a push/PR touching that many files as
+    # "everything changed" for the PATTERNS groups; language detection
+    # honors the same assumption so a consumer combining both outputs never
+    # sees a language silently excluded by the cap.
+    languages = (
+        sorted(set(LANGUAGE_EXTENSIONS.values()))
+        if files is not None and len(files)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Unclosed expression SyntaxError</b></div>
   <div id="fix">
   
   The `languages = (` expression at line 261 is never closed — the file ends 
at line 263 mid-ternary, so `python -m py_compile` fails with `SyntaxError: '(' 
was never closed`. The module cannot be imported, which also breaks 
`tests/unit_tests/scripts/change_detector_test.py` (`from scripts import 
change_detector`). Complete the expression with the `>= 99` cap and an `else` 
branch.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       languages = (
           sorted(set(LANGUAGE_EXTENSIONS.values()))
           if files is not None and len(files) >= 99
           else detect_languages(files)
       )
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #d63e48</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



##########
scripts/change_detector.py:
##########
@@ -217,43 +254,10 @@ def main(event_type: str, sha: str, repo: str) -> None:
             files, patterns_compiled
         )
 
-    # Output results
-    output_path = os.getenv("GITHUB_OUTPUT") or "/tmp/GITHUB_OUTPUT.txt"  # 
noqa: S108
-    with open(output_path, "a") as f:
-        for check, changed in changes_detected.items():
-            # NOTE: as noted above, we assume that if 100 files are touched, 
we should
-            # trigger all checks. This is a workaround for the GitHub API 
limit of 100
-            # files. Using >= 99 because off-by-one errors are not uncommon
-            if changed or (files is not None and len(files) >= 99):
-                print(f"{check}=true", file=f)
-                print(f"Triggering group: {check}")
-
-
-def get_git_sha() -> str:
-    return os.getenv("GITHUB_SHA") or subprocess.check_output(  # noqa: S603
-        ["git", "rev-parse", "HEAD"]  # noqa: S603, S607
-    ).strip().decode("utf-8")
-
-
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(
-        description="Detect file changes based on event context"
-    )
-    parser.add_argument(
-        "--event-type",
-        default=os.getenv("GITHUB_EVENT_NAME") or "push",
-        help="The type of event that triggered the workflow",
-    )
-    parser.add_argument(
-        "--sha",
-        default=get_git_sha(),
-        help="The commit SHA for push events or PR head SHA",
-    )
-    parser.add_argument(
-        "--repo",
-        default=os.getenv("GITHUB_REPOSITORY") or "apache/superset",
-        help="GitHub repository in the format owner/repo",
-    )
-    args = parser.parse_args()
-
-    main(args.event_type, args.sha, args.repo)
+    # The 100-file API cap below treats a push/PR touching that many files as
+    # "everything changed" for the PATTERNS groups; language detection
+    # honors the same assumption so a consumer combining both outputs never
+    # sees a language silently excluded by the cap.
+    languages = (
+        sorted(set(LANGUAGE_EXTENSIONS.values()))
+        if files is not None and len(files)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Dead computed value</b></div>
   <div id="fix">
   
   Even after the syntax is fixed, `languages` is computed at lines 261-263 but 
never read — no print, no GITHUB_OUTPUT write, no return (grep shows the only 
reference is the assignment). The diff removed the output block that wrote 
`{check}=true`, so the language-detection feature produces no output for any 
consumer.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #d63e48</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]

Reply via email to