Repository navigation
Conversation
Like `update --check`, it reports whether the output file is up to date without writing it. POT-Creation-Date is ignored, and a missing output file counts as out of date, as with `update --check --init-missing`. Fixes python-babel#900 Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1444 +/- ##
==========================================
+ Coverage 93.62% 94.16% +0.54%
==========================================
Files 27 27
Lines 4973 5091 +118
==========================================
+ Hits 4656 4794 +138
+ Misses 317 297 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
One false-negative case on printf '_("Hello")\n' > app.py
pybabel extract --copyright-holder 'Old Organization' -o messages.pot app.py
pybabel extract --check --copyright-holder 'New Organization' -o messages.pot app.py
# exits 0: "is up to date"
pybabel extract --copyright-holder 'New Organization' -o messages.pot app.py
# changes "Copyright (C) 2026 Old Organization" to "... New Organization"
Reproduced on Linux CPython 3.10 and 3.14. The unchanged-option control passes, and check mode preserves the file's bytes and mtime. The existing CLI tests pass on 3.14 (23 passed). I used AI assistance for this review; no downstream application impact claimed. |
`Catalog.is_identical()` leaves out the header comment, so a changed `--copyright-holder` or `--header-comment` passed the check although a normal extraction rewrites those lines. Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
chrikrah
left a comment
There was a problem hiding this comment.
@manav4u Reproduced at 1fcd0ea, and the same-line-count --header-comment case too. Fixed in 701dc27: the check now also compares header_comment.
$ python -X utf8 -m pytest -q # 1fcd0ea, CLDR imported, .[dev]
8212 passed, 7 skipped, 2 xfailed
$ python -X utf8 -m pytest -q # 701dc27
8214 passed, 7 skipped, 2 xfailed
$ git checkout 1fcd0ea -- babel/messages/frontend.py && python -X utf8 -m pytest -q
2 failed, 8212 passed, 7 skipped, 2 xfailed # both test_extract_check_header_comment cases
$ pre-commit run --all-files # ruff v0.14.10
Passed
One cost: the header carries the current year, so last year's template fails --check once in January. I left it in, since a real extraction rewrites that line and the file really is stale. Should the year be masked the way POT-Creation-Date is, or is the January failure fine for your CI?
|
Confirmed on 701dc27: both the copyright-holder change and the same-line-count custom header now fail I don't have a downstream CI deployment to speak for. My preference would be to keep the year comparison as you have it: this option is documented as detecting what extraction would change, with POT-Creation-Date as the explicit exception. Masking the year would add another exception and could also hide a deliberately edited custom header. I'd leave that policy call to the maintainers rather than block this repair on it. AI-assisted local verification; no full-suite or hosted-CI claim. |
Fixes #900.
pybabel extract --checkwrites nothing and fails when the POT file would change, ignoring POT-Creation-Date.A missing file fails the check, the way
update --check --init-missingtreats a catalog it would create (frontend.py#L809-L812). In CI that catches a POT nobody committed yet. Should a missing file pass instead?