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

Prevent wrapping file locations containing white space #1120

Merged
merged 6 commits into from
Dec 10, 2024

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Aug 18, 2024

Closes #1078
Depends on #1105 (To see only the changes in this PR, look at the last two commits)

Since #1105 wraps file names containing white space in special unicode markers, we look out for them when
wrapping comments.

The fix overrides the _split method of TextWrapper where we manually generate the indivisible chunks, taking into
account enclosed file names.

I test the the wrapping behavior with gettext 0.22.5 (which includes the enclosing logic) to make sure it's consistent

@tomasr8
Copy link
Member Author

tomasr8 commented Aug 18, 2024

Interesting, calling super() inside a list comprehension does not work on python 3.9..

Copy link

codecov bot commented Aug 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.47%. Comparing base (0005c85) to head (ac3c999).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1120      +/-   ##
==========================================
+ Coverage   91.27%   91.47%   +0.20%     
==========================================
  Files          27       27              
  Lines        4619     4636      +17     
==========================================
+ Hits         4216     4241      +25     
+ Misses        403      395       -8     
Flag Coverage Δ
macos-12-3.10 ?
macos-12-3.11 ?
macos-12-3.12 ?
macos-12-3.13-dev ?
macos-12-3.8 ?
macos-12-3.9 ?
macos-12-pypy3.10 ?
macos-14-3.10 90.25% <100.00%> (?)
macos-14-3.11 90.18% <100.00%> (?)
macos-14-3.12 90.40% <100.00%> (?)
macos-14-3.13 90.40% <100.00%> (?)
macos-14-3.8 90.17% <100.00%> (?)
macos-14-3.9 90.17% <100.00%> (?)
macos-14-pypy3.10 90.25% <100.00%> (?)
ubuntu-22.04-3.10 ?
ubuntu-22.04-3.11 ?
ubuntu-22.04-3.12 ?
ubuntu-22.04-3.13-dev ?
ubuntu-22.04-3.8 ?
ubuntu-22.04-3.9 ?
ubuntu-22.04-pypy3.10 ?
ubuntu-24.04-3.10 90.27% <100.00%> (?)
ubuntu-24.04-3.11 90.20% <100.00%> (?)
ubuntu-24.04-3.12 90.42% <100.00%> (?)
ubuntu-24.04-3.13 90.42% <100.00%> (?)
ubuntu-24.04-3.8 90.20% <100.00%> (?)
ubuntu-24.04-3.9 90.20% <100.00%> (?)
ubuntu-24.04-pypy3.10 90.27% <100.00%> (?)
windows-2022-3.10 90.39% <100.00%> (+0.20%) ⬆️
windows-2022-3.11 90.32% <100.00%> (+0.20%) ⬆️
windows-2022-3.12 90.54% <100.00%> (+0.20%) ⬆️
windows-2022-3.13 90.54% <100.00%> (?)
windows-2022-3.13-dev ?
windows-2022-3.8 90.31% <100.00%> (+0.20%) ⬆️
windows-2022-3.9 90.31% <100.00%> (+0.20%) ⬆️
windows-2022-pypy3.10 90.39% <100.00%> (+0.20%) ⬆️

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.

@tomasr8 tomasr8 changed the title Prevent wrapping file locations containing white sapce Prevent wrapping file locations containing white space Aug 18, 2024
@akx
Copy link
Member

akx commented Sep 4, 2024

@tomasr8 Can you rebase now that #1105 was merged? Thanks!

@tomasr8
Copy link
Member Author

tomasr8 commented Sep 4, 2024

@tomasr8 Can you rebase now that #1105 was merged? Thanks!

Done ;)

babel/util.py Show resolved Hide resolved
@tomasr8
Copy link
Member Author

tomasr8 commented Nov 10, 2024

Rebased and fixed the tests caused by missing break_long_words=False in TextWrapper

@tomasr8 tomasr8 requested a review from akx November 14, 2024 23:24
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.

Small comment about the readability of the new splitter, now that I look at it again... 😅

babel/util.py Outdated Show resolved Hide resolved
Co-authored-by: Aarni Koskela <akx@iki.fi>
babel/util.py Outdated Show resolved Hide resolved
@tomasr8
Copy link
Member Author

tomasr8 commented Dec 9, 2024

Alright, should be good now :)

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.

That's a wrap!

@akx akx merged commit 9d25e67 into python-babel:master Dec 10, 2024
26 checks passed
@tomasr8 tomasr8 deleted the line-wrap branch December 10, 2024 07:05
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.

Long path with space lead to wrong PO file.
2 participants