Skip to content

False positive f-string SyntaxError #7778

Closed

Description

@youknowone
# x.py
f"{1:{{1}.pop()}{f'n'}}"
$ ruff x.py
error: Failed to parse x.py:1:16: f-string: single '}' is not allowed
x.py:1:16: E999 SyntaxError: f-string: single '}' is not allowed
Found 1 error.
$ ruff --version
ruff 0.0.292

Activity

  1. dhruvmanila commented on Oct 3, 2023

    @dhruvmanila
    Member

    Thanks for the bug report! It seems to be caused by the two {{ inside the format spec part. It seems that the rules for escaping {/} are different in and out of a format spec.

  2. added
    bugAn issue describing something that isn't working, or a PR that fixes a bug
    parserRelated to the parser
    on Oct 3, 2023
  3. self-assigned this
    on Oct 3, 2023
  4. added a commit that references this issue on Oct 3, 2023
    69b8136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugAn issue describing something that isn't working, or a PR that fixes a bugparserRelated to the parser

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions