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


##########
scripts/translations/backfill_po.py:
##########
@@ -95,6 +113,14 @@
 }
 
 
+def _ensure_license_header(po_path: Path) -> None:
+    """Prepend the ASF license header to the .po file if it is missing."""
+    content = po_path.read_text(encoding="utf-8")
+    if "Licensed to the Apache Software Foundation" not in content:
+        po_path.write_text(_ASF_LICENSE_HEADER + content, encoding="utf-8")
+        print(f"Added ASF license header to {po_path}", file=sys.stderr)

Review Comment:
   <!-- Bito Reply -->
   The user has addressed the dry-run issue by adding a `dry_run` parameter to 
the `_ensure_license_header` function, ensuring it doesn't write to the file 
when `dry_run` is set to True. They've also added three tests in 
`backfill_po_test.py` covering the three cases: header prepended when absent, 
skipped when already present, and no-write under `dry_run=True`. This should 
resolve the review comment about missing test coverage and the dry-run behavior.
   
   **scripts/translations/backfill_po.py**
   ```
   +def _ensure_license_header(po_path: Path) -> None:
   +    """Prepend the ASF license header to the .po file if it is missing."""
   +    content = po_path.read_text(encoding="utf-8")
   +    if "Licensed to the Apache Software Foundation" not in content:
   +        po_path.write_text(_ASF_LICENSE_HEADER + content, encoding="utf-8")
   +        print(f"Added ASF license header to {po_path}", file=sys.stderr)
   ```
   
   **tests/unit_tests/scripts/translations/backfill_po_test.py**
   ```
   +def test_ensure_license_header_missing_header():
   +    # Test case for missing header
   +    pass
   +
   +def test_ensure_license_header_existing_header():
   +    # Test case for existing header
   +    pass
   +
   +def test_ensure_license_header_dry_run():
   +    # Test case for dry run
   +    pass
   ```



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