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

Prevent wrapping file locations containing white space #1120

Open tomasr8 opened 3 months ago

tomasr8 commented 3 months ago

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 commented 3 months ago

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

codecov[bot] commented 3 months ago

Codecov Report

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

Project coverage is 91.29%. Comparing base (0005c85) to head (89602b4).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1120 +/- ## ========================================== + Coverage 91.27% 91.29% +0.02% ========================================== Files 27 27 Lines 4619 4630 +11 ========================================== + Hits 4216 4227 +11 Misses 403 403 ``` | [Flag](https://app.codecov.io/gh/python-babel/babel/pull/1120/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/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.06% <100.00%> (+0.02%)` | :arrow_up: | | [macos-12-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1120/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.02%)` | :arrow_up: | | [macos-12-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.21% <100.00%> (+0.02%)` | :arrow_up: | | [macos-12-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1120/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.02%)` | :arrow_up: | | [macos-12-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.99% <100.00%> (+0.02%)` | :arrow_up: | | [macos-12-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.99% <100.00%> (+0.02%)` | :arrow_up: | | [macos-12-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.06% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.08% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.02% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.23% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.76% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.01% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.01% <100.00%> (+0.02%)` | :arrow_up: | | [ubuntu-22.04-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.08% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1120/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.02%)` | :arrow_up: | | [windows-2022-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.14% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.35% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.88% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.13% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1120/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.13% <100.00%> (+0.02%)` | :arrow_up: | | [windows-2022-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1120/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.02%)` | :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.

akx commented 3 months ago

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

tomasr8 commented 3 months ago

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

Done ;)

tomasr8 commented 3 weeks ago

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