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

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

dylankiss
Copy link
Contributor

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 #1123

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.

LGTM, thanks!

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 python-babel#1123
@akx akx enabled auto-merge (squash) October 19, 2024 12:14
Copy link

codecov bot commented Oct 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1126   +/-   ##
=======================================
  Coverage   91.30%   91.31%           
=======================================
  Files          27       27           
  Lines        4610     4615    +5     
=======================================
+ Hits         4209     4214    +5     
  Misses        401      401           
Flag Coverage Δ
macos-12-3.10 90.07% <71.42%> (-0.04%) ⬇️
macos-12-3.11 90.01% <71.42%> (-0.04%) ⬇️
macos-12-3.12 90.22% <100.00%> (+0.01%) ⬆️
macos-12-3.13-dev 89.75% <100.00%> (+0.01%) ⬆️
macos-12-3.8 90.00% <71.42%> (-0.04%) ⬇️
macos-12-3.9 90.00% <71.42%> (-0.04%) ⬇️
macos-12-pypy3.10 90.07% <71.42%> (-0.04%) ⬇️
ubuntu-22.04-3.10 90.09% <71.42%> (-0.04%) ⬇️
ubuntu-22.04-3.11 90.03% <71.42%> (-0.04%) ⬇️
ubuntu-22.04-3.12 90.24% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.13-dev 89.77% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.8 90.02% <71.42%> (-0.04%) ⬇️
ubuntu-22.04-3.9 90.02% <71.42%> (-0.04%) ⬇️
ubuntu-22.04-pypy3.10 90.09% <71.42%> (-0.04%) ⬇️
windows-2022-3.10 90.21% <71.42%> (-0.04%) ⬇️
windows-2022-3.11 90.15% <71.42%> (-0.04%) ⬇️
windows-2022-3.12 90.36% <100.00%> (+0.01%) ⬆️
windows-2022-3.13-dev 89.89% <100.00%> (+0.01%) ⬆️
windows-2022-3.8 90.14% <71.42%> (-0.04%) ⬇️
windows-2022-3.9 90.14% <71.42%> (-0.04%) ⬇️
windows-2022-pypy3.10 90.21% <71.42%> (-0.04%) ⬇️

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.

@akx akx merged commit bef3a73 into python-babel:master Oct 19, 2024
26 checks passed
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.

extract: Wrong lineno when arguments are spread over multiple lines and contain a function call
2 participants