Skip to content

handle Python concatenated strings in Rust dependency inference parser #22050

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

Merged
merged 14 commits into from
Mar 9, 2025

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Mar 6, 2025

As reported in #20324, the Rust-based Python import parser does not handle certain valid source patterns including concatenated strings.

Fix the Rust-based parser to handle concatenated strings correctly. Strings are parsed out of Nodes via the new extract_string helper. The insert_import function is refactored to avoid double parsing of strings.

Added some tests as well for concatenated strings.

@tdyas tdyas changed the title [WIP] handle Python concatenated strings in Rust dependency inference parser handle Python concatenated strings in Rust dependency inference parser Mar 7, 2025
@tdyas tdyas requested review from huonw and tgolsson March 7, 2025 04:44
@tdyas tdyas marked this pull request as ready for review March 7, 2025 04:45
@tdyas tdyas requested a review from benjyw March 7, 2025 05:19
@tdyas tdyas merged commit 7e1467e into pantsbuild:main Mar 9, 2025
24 checks passed
@WorkerPants
Copy link
Member

I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants.

✔️ 2.24.x

Successfully opened #22062.

✔️ 2.25.x

Successfully opened #22063.


Thanks again for your contributions!

🤖 Beep Boop here's my run link

tdyas added a commit that referenced this pull request Mar 9, 2025
…r (Cherry-pick of #22050) (#22063)

As reported in #20324, the
Rust-based Python import parser does not handle certain valid source
patterns including concatenated strings.

Fix the Rust-based parser to handle concatenated strings correctly.
Strings are parsed out of `Node`s via the new `extract_string` helper.
The `insert_import` function is refactored to avoid double parsing of
strings.

Added some tests as well for concatenated strings.

Co-authored-by: Tom Dyas <[email protected]>
tdyas added a commit that referenced this pull request Mar 9, 2025
…r (Cherry-pick of #22050) (#22062)

As reported in #20324, the
Rust-based Python import parser does not handle certain valid source
patterns including concatenated strings.

Fix the Rust-based parser to handle concatenated strings correctly.
Strings are parsed out of `Node`s via the new `extract_string` helper.
The `insert_import` function is refactored to avoid double parsing of
strings.

Added some tests as well for concatenated strings.

Co-authored-by: Tom Dyas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants