You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/07/16 05:28:02 UTC
[PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
rusackas opened a new pull request, #42103:
URL: https://github.com/apache/superset/pull/42103
### SUMMARY
`scripts/translations/backfill_po.py` validates the `--lang` code before it lands in a filesystem path. The pattern only allowed an optional `_<REGION>` subtag:
```
[a-z]{2,3}(_[A-Z]{2})?
```
That rejects catalogs whose code carries an ISO 15924 **script** subtag — most notably `sr_Latn` (Serbian in Latin script), which exists in `superset/translations/`. Running `backfill_po.py --lang sr_Latn` failed with `Invalid language code`, so the backfill silently skipped that catalog (I hit exactly this while backfilling gaps — `sr_Latn` came back with 0 entries filled and no obvious error).
This widens the pattern to also accept a titlecase script subtag and pulls the check into a small `_is_valid_lang_code` helper so it's unit-testable:
```
[a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?
```
Path-traversal protection is unchanged (`fullmatch`, same character classes).
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/scripts/translations/backfill_po_test.py
```
New tests cover `fr` / `pt_BR` / `sr_Latn` (accepted) and malformed / traversal inputs like `fr_br`, `../etc`, `sr-Latn` (rejected).
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Changes UI
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #42103:
URL: https://github.com/apache/superset/pull/42103
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42103:
URL: https://github.com/apache/superset/pull/42103#issuecomment-4989879951
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42103:
URL: https://github.com/apache/superset/pull/42103#issuecomment-4988523143
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42103:
URL: https://github.com/apache/superset/pull/42103#issuecomment-4988677327
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42103?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 64.27%. Comparing base ([`8603048`](https://app.codecov.io/gh/apache/superset/commit/86030485180c292eee801bbce50a8a8fee918b5c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`58318ce`](https://app.codecov.io/gh/apache/superset/commit/58318ce2f47ef147c39cf427129856f9e5359df3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 2 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #42103 +/- ##
==========================================
- Coverage 65.09% 64.27% -0.83%
==========================================
Files 2752 2752
Lines 154439 154439
Branches 35397 35397
==========================================
- Hits 100535 99264 -1271
- Misses 51992 53273 +1281
+ Partials 1912 1902 -10
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.02% <ø> (ø)` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.00% <ø> (ø)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.57% <ø> (-1.68%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.43% <ø> (ø)` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/42103/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42103?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42103:
URL: https://github.com/apache/superset/pull/42103#discussion_r3592857804
##########
scripts/translations/backfill_po.py:
##########
@@ -138,6 +138,22 @@ def _lang_name(code: str) -> str:
return LANGUAGE_NAMES.get(code, code)
+# An ISO 639-1/639-2 code, optionally followed by an ISO 3166 region
+# (``_BR``, two uppercase) or an ISO 15924 script (``_Latn``, titlecase). The
+# script subtag matters for catalogs like ``sr_Latn`` (Serbian in Latin script);
+# without it the code was rejected and the catalog silently skipped.
+_LANG_CODE_RE = re.compile(r"[a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?")
Review Comment:
**Suggestion:** Add an explicit type annotation for this compiled regex constant (for example, a pattern type) to satisfy the typing requirement for new variables. [custom_rule]
**Severity Level:** Minor 🧹
<details>
<summary><b>Why it matters? ⭐ </b></summary>
The new module-level regex constant is unannotated even though it can be typed, which matches the rule requiring type hints on relevant new Python variables.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=af285955fe6945bd92b674ebf1a9c295&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=af285955fe6945bd92b674ebf1a9c295&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:** scripts/translations/backfill_po.py
**Line:** 145:145
**Comment:**
*Custom Rule: Add an explicit type annotation for this compiled regex constant (for example, a pattern type) to satisfy the typing requirement for new variables.
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%2F42103&comment_hash=55885710e6990ddab779407e7b0a18dfef5de7e0b98837114fa277de4f2e8519&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42103&comment_hash=55885710e6990ddab779407e7b0a18dfef5de7e0b98837114fa277de4f2e8519&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42103:
URL: https://github.com/apache/superset/pull/42103#issuecomment-4988532591
<!-- Bito Reply -->
The suggestion to add an explicit type annotation to the `_LANG_CODE_RE` constant is correct and aligns with standard Python typing practices for module-level constants. You can resolve this by importing `Pattern` from the `re` module and annotating the variable as follows:
```python
import re
from typing import Pattern
_LANG_CODE_RE: Pattern[str] = re.compile(r"[a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?")
```
There are no other comments on this pull request to address. Would you like me to implement this change for you?
**scripts/translations/backfill_po.py**
```
import re
from typing import Pattern
_LANG_CODE_RE: Pattern[str] = re.compile(r"[a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?")
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(i18n): accept script subtags (e.g. sr_Latn) in backfill_po language codes [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #42103:
URL: https://github.com/apache/superset/pull/42103#discussion_r3592899149
##########
scripts/translations/backfill_po.py:
##########
@@ -138,6 +138,22 @@ def _lang_name(code: str) -> str:
return LANGUAGE_NAMES.get(code, code)
+# An ISO 639-1/639-2 code, optionally followed by an ISO 3166 region
+# (``_BR``, two uppercase) or an ISO 15924 script (``_Latn``, titlecase). The
+# script subtag matters for catalogs like ``sr_Latn`` (Serbian in Latin script);
+# without it the code was rejected and the catalog silently skipped.
+_LANG_CODE_RE = re.compile(r"[a-z]{2,3}(_([A-Z]{2}|[A-Z][a-z]{3}))?")
Review Comment:
Done, annotated as `re.Pattern[str]`.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org