RustPython / RustPython/Parser
Incorrect f-string parsing
Open
Nobody has claimed this yet.
bug
- Dominant language
- Rust
- Stars
- 117
- Forks
- 38
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 1
Description
Originally reported as https://github.com/astral-sh/ruff/issues/5044:
Not the best string ever, but ruff doesn't handle it like Python
λ cat test.py print(f"$N_{{img}}\in\{{0,1,2\}}$") λ python test.py $N_{img}\in\{0,1,2\}$ λ ruff check test.py --select F401 error: Failed to parse test.py:1:25: f-string: unterminated string
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the provided test.py contents and compare Python's output with ruff check test.py --select F401. Trace how this f-string is parsed and ensure the parser accepts the escaped braces and backslashes instead of reporting an unterminated string. Done means the example parses without the reported error and matches Python's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100