Skip to content

Add a --check mode to the extract command - #1444

Open
chrikrah wants to merge 1 commit into
python-babel:masterfrom
chrikrah:extract-check-900
Open

chrikrah wants to merge 1 commit into
python-babel:masterfrom
chrikrah:extract-check-900

Conversation

@chrikrah

@chrikrah chrikrah commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #900.

pybabel extract --check writes nothing and fails when the POT file would change, ignoring POT-Creation-Date.

$ pybabel extract -o messages.pot app && pybabel extract --check -o messages.pot app
PO template file messages.pot is up to date.                         # exit 0
$ echo 'print(_("Bye"))' >> app/a.py && pybabel extract --check -o messages.pot app
babel.messages.frontend.BaseError: PO template file messages.pot is out of date.   # exit 1

$ python -X utf8 -m pytest -q                       # at a18709c, CLDR imported
8210 passed, 7 skipped, 2 xfailed                    # base
8212 passed, 7 skipped, 2 xfailed                    # this branch
2 failed, 21 passed                                  # tests/messages/frontend/test_cli.py with frontend.py from a18709c
$ pre-commit run --all-files                         # ruff 0.14.10 and the rest: Passed

A missing file fails the check, the way update --check --init-missing treats a catalog it would create (frontend.py#L809-L812). In CI that catches a POT nobody committed yet. Should a missing file pass instead?

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

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.70%. Comparing base (a18709c) to head (1fcd0ea).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1444      +/-   ##
==========================================
+ Coverage   93.62%   93.70%   +0.07%     
==========================================
  Files          27       27              
  Lines        4973     4987      +14     
==========================================
+ Hits         4656     4673      +17     
+ Misses        317      314       -3     
Flag Coverage Δ
macos-15-3.10 92.78% <100.00%> (?)
macos-15-3.11 92.72% <100.00%> (?)
macos-15-3.12 92.98% <100.00%> (?)
macos-15-3.13 92.98% <100.00%> (+0.08%) ⬆️
macos-15-3.14 92.96% <100.00%> (?)
macos-15-3.15 92.96% <100.00%> (+0.08%) ⬆️
macos-15-3.9 92.71% <100.00%> (?)
macos-15-pypy3.10 92.78% <100.00%> (?)
ubuntu-24.04-3.10 92.80% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-3.11 92.74% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-3.12 93.00% <100.00%> (?)
ubuntu-24.04-3.13 93.00% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-3.14 92.98% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-3.15 92.98% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-3.9 92.73% <100.00%> (+0.08%) ⬆️
ubuntu-24.04-pypy3.10 92.80% <100.00%> (+0.08%) ⬆️
windows-2022-3.10 92.79% <100.00%> (+0.08%) ⬆️
windows-2022-3.11 92.73% <100.00%> (?)
windows-2022-3.12 92.99% <100.00%> (?)
windows-2022-3.13 92.99% <100.00%> (?)
windows-2022-3.14 92.97% <100.00%> (?)
windows-2022-3.15 92.97% <100.00%> (+0.08%) ⬆️
windows-2022-3.9 92.72% <100.00%> (+0.08%) ⬆️
windows-2022-pypy3.10 92.79% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Nov 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing chrikrah:extract-check-900 (1fcd0ea) with master (a18709c)

Open in CodSpeed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check mode for exctract command

1 participant