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 extracted lineno with nested calls #1126

Closed dylankiss closed 1 month ago

dylankiss commented 2 months ago

When a gettext call had a nested function call on a new line, the extract function would use that nested call's line number when extracting the terms for the gettext call.

The reason is that we set the line number on any encounter of an opening parenthesis after a gettext keyword. This does not work if either we have a nested call, or our first term starts on a new line.

This commit fixes that by only setting the line number when we encounter the first argument inside a gettext call.

Existing tests were adapted to work according to xgettext with regards to the line numbers.

Fixes https://github.com/python-babel/babel/issues/1123

codecov[bot] commented 1 month ago

Codecov Report

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

Project coverage is 91.31%. Comparing base (ea84d9d) to head (5795711). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1126 +/- ## ======================================= Coverage 91.30% 91.31% ======================================= Files 27 27 Lines 4610 4615 +5 ======================================= + Hits 4209 4214 +5 Misses 401 401 ``` | [Flag](https://app.codecov.io/gh/python-babel/babel/pull/1126/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/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.07% <71.42%> (-0.04%)` | :arrow_down: | | [macos-12-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.01% <71.42%> (-0.04%)` | :arrow_down: | | [macos-12-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1126/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: | | [macos-12-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.75% <100.00%> (+0.01%)` | :arrow_up: | | [macos-12-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.00% <71.42%> (-0.04%)` | :arrow_down: | | [macos-12-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.00% <71.42%> (-0.04%)` | :arrow_down: | | [macos-12-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.07% <71.42%> (-0.04%)` | :arrow_down: | | [ubuntu-22.04-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.09% <71.42%> (-0.04%)` | :arrow_down: | | [ubuntu-22.04-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.03% <71.42%> (-0.04%)` | :arrow_down: | | [ubuntu-22.04-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.24% <100.00%> (+0.01%)` | :arrow_up: | | [ubuntu-22.04-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.77% <100.00%> (+0.01%)` | :arrow_up: | | [ubuntu-22.04-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.02% <71.42%> (-0.04%)` | :arrow_down: | | [ubuntu-22.04-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.02% <71.42%> (-0.04%)` | :arrow_down: | | [ubuntu-22.04-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.09% <71.42%> (-0.04%)` | :arrow_down: | | [windows-2022-3.10](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.21% <71.42%> (-0.04%)` | :arrow_down: | | [windows-2022-3.11](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.15% <71.42%> (-0.04%)` | :arrow_down: | | [windows-2022-3.12](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.36% <100.00%> (+0.01%)` | :arrow_up: | | [windows-2022-3.13-dev](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `89.89% <100.00%> (+0.01%)` | :arrow_up: | | [windows-2022-3.8](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.14% <71.42%> (-0.04%)` | :arrow_down: | | [windows-2022-3.9](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.14% <71.42%> (-0.04%)` | :arrow_down: | | [windows-2022-pypy3.10](https://app.codecov.io/gh/python-babel/babel/pull/1126/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-babel) | `90.21% <71.42%> (-0.04%)` | :arrow_down: | 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.