Repository navigation
Accept backslashes before f-string replacement fields - #253
Closed
rupayon123 wants to merge 1 commit into
Closed
rupayon123 wants to merge 1 commit into
rupayon123 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backslashes before braces in f-string literal text were being consumed together with the brace. This rejects valid replacement fields such as
rf"\{value}", including the example in #207.Keep the backslash as literal text and let the normal brace rules handle replacement fields and doubled braces. Named Unicode escapes and other escapes retain their existing branches. Both single-line and triple-quoted f-strings use the corrected rule.
Regression coverage includes ordinary/raw f-strings, format specifications, doubled braces, the original nested-call example, and rejection of a backslash followed by an unmatched closing brace. The 109 valid-input cases failed before the fix.
Validation on Python 3.12.13:
python -m pytest -q— 2,102 passed.zuban check --python-executable ../parso/.venv/bin/python— no issues in 49 files. The explicit interpreter selects the shared test environment for this worktree.git diff --checkpassed.Local grammar coverage spans 3.6–3.14; the GitHub runtime matrix has not run yet.
Fixes #207.