python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.34k stars 448 forks source link

Fix `pybabel update --init-missing` not creating parent directory #1142

Open du33169 opened 1 month ago

du33169 commented 1 month ago

Replaced the redundant init logic in UpdateCatalog.run() with a temporary InitCatalog instance to ensure the parent directory of the output file will be created. (close #1139)

codecov[bot] commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.28%. Comparing base (313277a) to head (3a47a5c).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1142 +/- ## ======================================= Coverage 91.28% 91.28% ======================================= Files 27 27 Lines 4623 4624 +1 ======================================= + Hits 4220 4221 +1 Misses 403 403 ``` | [Flag](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | Coverage Δ | | |---|---|---| | [macos-12-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.05% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.98% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.20% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.72% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.98% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.98% <100.00%> (+<0.01%)` | :arrow_up: | | [macos-12-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.05% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.07% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.00% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.22% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.74% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.00% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.00% <100.00%> (+<0.01%)` | :arrow_up: | | [ubuntu-22.04-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.07% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.19% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.12% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.34% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.86% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.12% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.12% <100.00%> (+<0.01%)` | :arrow_up: | | [windows-2022-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1142/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.19% <100.00%> (+<0.01%)` | :arrow_up: | 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=python-babel#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

du33169 commented 2 weeks ago

Could we get some sort of test for this? Does the (re)use of InitCatalog do exactly the same thing as the old code?

The original logic replaced in UpdateCatalog is the same as InitCatalog.run(). To resolve the corresponding issue, we need the directory creation logic in InitCatalog.finalize_options(). I haven't investigated on what else will be done in the constructor.

Will it be better to elevate the logic of InitCatalog.run() and InitCatalog.finalize_options() to classmethods? Or should we make it simple, by just adding the directory creation logic again, and leave the redundancy for now?