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

Avoid moving back the lexer for triple-quoted fstring #11939

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jun 19, 2024

Summary

This PR avoids moving back the lexer for a triple-quoted f-string during the re-lexing phase.

The reason this is a problem is that for a triple-quoted f-string the newlines are part of the f-string itself, specifically they'll be part of the FStringMiddle token. So, if we moved the lexer back, there would be a Newline token whose range would be in between an FStringMiddle token. This creates a panic in downstream usage.

fixes: #11937

Test Plan

Add test cases and validate the snapshots.

@dhruvmanila dhruvmanila added bug Something isn't working parser Related to the parser labels Jun 19, 2024
Copy link
Contributor

github-actions bot commented Jun 19, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@dhruvmanila dhruvmanila marked this pull request as ready for review June 20, 2024 09:00
@dhruvmanila dhruvmanila merged commit ed948ea into main Jun 20, 2024
20 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/re-lexing-fstring-bug branch June 20, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Related to the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule PYI010 cause panic
2 participants