You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sadpandajoe (via GitHub)" <gi...@apache.org> on 2026/09/23 21:32:58 UTC
[PR] fix(i18n): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
sadpandajoe opened a new pull request, #44584:
URL: https://github.com/apache/superset/pull/44584
### SUMMARY
`Python-Unit` has been red on master because the `unit-tests (next)` leg (Python 3.12, push-only) fails `check_pot_drift_test.py::test_committed_template_matches_a_fresh_extraction`:
```
AssertionError: 1 string(s) in source missing from messages.pot
assert not {'valuename'}
```
**Root cause:** `QueryContextProcessor.get_viz_annotation_data` passed two f-strings to `_()`. On Python 3.11 babel's extractor drops an f-string entirely. Under Python 3.12 (PEP 701) f-strings are tokenized into parts, and babel collects the dict-key literals inside the replacement fields (`annotation_layer["value"]`, `annotation_layer["name"]`) and concatenates them into the msgid `"valuename"` (the second site yields `"name"`, which is hidden because that msgid already exists). `messages.pot` is generated on 3.11, so the drift check only disagrees on 3.12. PR CI only runs the `current` Python leg, so this slipped through when the drift test was added in #44467.
**Fix:** use parameterized gettext (`%(chart_id)s`, `%(layer_name)s`) at both sites, which also makes these messages translatable for the first time (an f-string msgid can never match a catalog entry), and regenerate `messages.pot`. These were the only `_(f"...")` calls in `superset/`. The `.po` catalogs are left to the regular translation sync to keep this diff minimal.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
PR CI only runs Python 3.11, so it will not exercise the failing leg. Verified locally:
- Python 3.11.9: `python scripts/translations/check_pot_drift.py` reports the template matches a fresh extraction, and `pytest tests/unit_tests/scripts/translations/check_pot_drift_test.py` passes (7 passed)
- Python 3.12.13 (babel 2.17.0): `check_pot_drift.diff()` returns `missing=set(), stale=set()`. Before the fix it returned `missing={'valuename'}`
- New unit tests in `tests/unit_tests/common/test_query_context_processor.py` assert the rendered text of both error messages
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #44584:
URL: https://github.com/apache/superset/pull/44584
--
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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44584:
URL: https://github.com/apache/superset/pull/44584#issuecomment-5803298510
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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44584:
URL: https://github.com/apache/superset/pull/44584#issuecomment-5803811844
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44584?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 65.88%. Comparing base ([`082961b`](https://app.codecov.io/gh/apache/superset/commit/082961ba168f18422a356c2df8b724d735eec9ca?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ba86db2`](https://app.codecov.io/gh/apache/superset/commit/ba86db28eea82b18d34f33ff8f49692a6f1378f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (082961b) and HEAD (ba86db2). Click for more details.
>
> <details><summary>HEAD has 4 uploads less than BASE</summary>
>
>| Flag | BASE (082961b) | HEAD (ba86db2) |
>|------|------|------|
>|python|7|3|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44584 +/- ##
===========================================
- Coverage 81.06% 65.88% -15.18%
===========================================
Files 2955 2955
Lines 178319 178319
Branches 41312 41312
===========================================
- Hits 144549 117482 -27067
- Misses 31060 58317 +27257
+ Partials 2710 2520 -190
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44584/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/44584/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.80% <ø> (ø)` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/44584/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/44584/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/44584/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.70% <ø> (ø)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/44584/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.84% <ø> (-29.53%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/44584/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.71% <ø> (ø)` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/44584/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/44584?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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44584:
URL: https://github.com/apache/superset/pull/44584#issuecomment-5803899429
<!-- Bito Reply -->
Adding `extend-function-names = ["__"]` to `[tool.ruff.lint.flake8-gettext]` is a recommended improvement to ensure consistency between Babel's extraction and Ruff's linting. Since `__` is used as a keyword for translation, explicitly configuring Ruff to recognize it will prevent `INT001` from missing these calls, even if it is not currently blocking any issues in the codebase.
--
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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #44584:
URL: https://github.com/apache/superset/pull/44584#discussion_r4087872892
##########
pyproject.toml:
##########
@@ -455,6 +455,9 @@ select = [
"F",
"G",
"I",
+ # f-strings passed to gettext are never translatable, and on Python
+ # 3.12+ babel extracts bogus msgids from their replacement fields.
+ "INT001",
Review Comment:
INT001 only checks `_`, `gettext` and `ngettext` by default, so `__(f"...")` still slips through, even though `__` is one of the `-k` keywords babel extracts. I checked it with `ruff --select INT001` on a scratch file.
Nothing in `superset/` uses `__` that way at the moment, so it's not blocking. Worth adding `extend-function-names = ["__"]` under `[tool.ruff.lint.flake8-gettext]` so the guard matches what babel extracts?
--
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): stop f-strings in gettext leaking a bogus msgid on Python 3.12 [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44584:
URL: https://github.com/apache/superset/pull/44584#issuecomment-5805483019
**Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it
--
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