Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

du33169
Copy link

@du33169 du33169 commented Oct 28, 2024

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)

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

babel/messages/frontend.py Outdated Show resolved Hide resolved
Comment on lines +783 to 793
tmpInitCatalog = InitCatalog(self.distribution)
tmpInitCatalog.output_dir = None
tmpInitCatalog.output_file = filename
tmpInitCatalog.input_file = self.input_file
tmpInitCatalog.locale = self.locale
tmpInitCatalog.domain = self.domain
tmpInitCatalog.no_wrap = self.no_wrap
tmpInitCatalog.width = self.width
tmpInitCatalog.finalize_options()
tmpInitCatalog.run()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable names should be in snake_case, not camelCase.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1142   +/-   ##
=======================================
  Coverage   91.28%   91.28%           
=======================================
  Files          27       27           
  Lines        4623     4624    +1     
=======================================
+ Hits         4220     4221    +1     
  Misses        403      403           
Flag Coverage Δ
macos-12-3.10 90.05% <100.00%> (+<0.01%) ⬆️
macos-12-3.11 89.98% <100.00%> (+<0.01%) ⬆️
macos-12-3.12 90.20% <100.00%> (+<0.01%) ⬆️
macos-12-3.13-dev 89.72% <100.00%> (+<0.01%) ⬆️
macos-12-3.8 89.98% <100.00%> (+<0.01%) ⬆️
macos-12-3.9 89.98% <100.00%> (+<0.01%) ⬆️
macos-12-pypy3.10 90.05% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.10 90.07% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.11 90.00% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.12 90.22% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.13-dev 89.74% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.8 90.00% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-3.9 90.00% <100.00%> (+<0.01%) ⬆️
ubuntu-22.04-pypy3.10 90.07% <100.00%> (+<0.01%) ⬆️
windows-2022-3.10 90.19% <100.00%> (+<0.01%) ⬆️
windows-2022-3.11 90.12% <100.00%> (+<0.01%) ⬆️
windows-2022-3.12 90.34% <100.00%> (+<0.01%) ⬆️
windows-2022-3.13-dev 89.86% <100.00%> (+<0.01%) ⬆️
windows-2022-3.8 90.12% <100.00%> (+<0.01%) ⬆️
windows-2022-3.9 90.12% <100.00%> (+<0.01%) ⬆️
windows-2022-pypy3.10 90.19% <100.00%> (+<0.01%) ⬆️

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

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

Co-authored-by: Aarni Koskela <[email protected]>
@du33169
Copy link
Author

du33169 commented Nov 18, 2024

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?

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.

option --init-missing of pybabel update should also create the corresponding directory
2 participants