-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
EOF in multi-line string error for valid format string #4588
Comments
Minimized link if f"\\":'{1}' The quotes have to be different and the first string has to be a f-string.
The issue starts at this line pseudomatch = pseudoprog.match(line, pos) Where the match is fstring_middle = line[start + offset : end_offset] So the issue looks to be that the
Looking through the debugger, the faulty part is this: # beginning of a single quoted f-string. must not end with `{{` or `\N{`
SingleLbrace = r"(?:\\N{|{{|\\'|[^\n'{])*(?<!\\N)({)(?!{)"
DoubleLbrace = r'(?:\\N{|{{|\\"|[^\n"{])*(?<!\\N)({)(?!{)' but the area of the issue is slightly different, cc @tusharsadhwani both because you'd know better how to fix it and this would be a good case to add to #4536 |
this already parses correctly with the new tokenizer :D |
Describe the bug
Black errs on format string while Python runs the code without error.
To Reproduce
And run it with these arguments:
The resulting error is:
Expected behavior
The same code but formatted. Python does accept this input and will print
y
.Environment
$ black --version black, 25.1.0 (compiled: yes) Python (CPython) 3.10.12 $ python3 --version Python 3.10.12 $ uname -a Linux ubuntu 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: