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


##########
scripts/compile_po.py:
##########
@@ -0,0 +1,166 @@
+#!/usr/bin/env python3
+# 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.
+
+# This script is a cross-platform Python equivalent of po2json.sh.
+# It generates .json files from .po translation files used by the frontend.
+
+import glob
+import os
+import shutil
+import subprocess
+import sys
+from concurrent.futures import ThreadPoolExecutor, as_completed
+
+_SHELL = os.name == "nt"
+
+
+def run_command(command: list[str], cwd: str | None = None, timeout: int = 
120) -> int:
+    try:
+        result = subprocess.run(  # noqa: S603
+            command, text=True, shell=_SHELL, check=False, cwd=cwd, 
timeout=timeout
+        )
+        return result.returncode
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return 1
+
+
+def find_command(names: list[str]) -> str | None:
+    for name in names:
+        path = shutil.which(name)
+        if path:
+            return path
+    return None
+
+
+def install_npm_packages(npm_cmd: str, root_dir: str, packages: list[str]) -> 
bool:
+    rc = run_command(
+        [npm_cmd, "install", "--no-save", "--prefer-offline", *packages],
+        cwd=root_dir,
+    )
+    return rc == 0
+
+
+def convert_po_file(
+    po_file: str, frontend_trans_dir: str, po2json_cmd: list[str], npx_cmd: 
str | None

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Dead parameter in function</b></div>
   <div id="fix">
   
   The `npx_cmd` parameter in `convert_po_file` is defined but never used 
inside the function body. It is passed at line 137 but never referenced after 
line 69. Removing it eliminates dead parameter noise and clarifies the function 
contract.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    -    po_file: str, frontend_trans_dir: str, po2json_cmd: list[str], 
npx_cmd: str | None
    +    po_file: str, frontend_trans_dir: str, po2json_cmd: list[str]
     ) -> tuple[bool, str, str]:
         locale_rel = os.path.relpath(po_file, 
start=os.path.dirname(os.path.dirname(po_file)))
         json_dest = os.path.join(frontend_trans_dir, 
os.path.splitext(locale_rel)[0] + ".json")
         os.makedirs(os.path.dirname(json_dest), exist_ok=True)
    
         cmd = [*po2json_cmd, "--domain", "superset", "--format", "jed1.x", 
"--fuzzy", po_file, json_dest]
         rc = run_command(cmd, timeout=60)
         if rc != 0:
             return False, po_file, f"po2json failed (rc={rc})"
         return True, po_file, ""
    @@ -135,5 +135,5 @@
             futures = {
    -            executor.submit(convert_po_file, f, frontend_trans_dir, 
po2json_cmd, npx_cmd): f
    +            executor.submit(convert_po_file, f, frontend_trans_dir, 
po2json_cmd): f
                 for f in po_files
             }
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #7db413</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