Skip to content

Ignore trailing quotes for unclosed l-brace errors#9388

Merged
charliermarsh merged 1 commit intomainfrom
charlie/f-string-err
Jan 4, 2024
Merged

Ignore trailing quotes for unclosed l-brace errors#9388
charliermarsh merged 1 commit intomainfrom
charlie/f-string-err

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Summary

Given:

F"{"ڤ

We try to locate the "unclosed left brace" error by subtracting the quote size from the lexer offset -- so we subtract 1 from the end of the source, which puts us in the middle of a Unicode character. I don't think we should try to adjust the offset in this way, since there can be content after the quote. For example, with the advent of PEP 701, this string could reasonably be fixed as:

F"{"ڤ"}"

Closes #9379.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 4, 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.

@charliermarsh charliermarsh marked this pull request as ready for review January 4, 2024 04:55
@charliermarsh charliermarsh enabled auto-merge (squash) January 4, 2024 04:55
@charliermarsh charliermarsh merged commit f0d43da into main Jan 4, 2024
@charliermarsh charliermarsh deleted the charlie/f-string-err branch January 4, 2024 05:00
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.

Linter panic: f-string error location miscomputation

1 participant