Skip to content
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

Cannot parse f-string. #4046

Closed
Hendler opened this issue Nov 14, 2023 · 1 comment
Closed

Cannot parse f-string. #4046

Hendler opened this issue Nov 14, 2023 · 1 comment
Labels
T: bug Something isn't working

Comments

@Hendler
Copy link

Hendler commented Nov 14, 2023

File can not be formatted

from datetime import datetime
created = 1699960500
dt = datetime.fromtimestamp(created)
a = "hello"
n = "world"
print(f"{a}. {n} ({dt.strftime("%Y-%m-%d-%H:%M:%S")})")

And run it with these arguments:

$ black file.py

The resulting error is:

error: cannot format file.py:
Cannot parse: 9:35: print(f"{a}. {n} ({dt.strftime("%Y-%m-%d-%H:%M:%S")})")

Expected behavior

Passes black or makes correction.
Perhaps this is resolved elsewhere. e.g. #1132

Environment

  • Black's version: black==23.11.0
  • OS and Python version: MacOS 14.0 (23A344) , Python 3.12.0
@Hendler Hendler added the T: bug Something isn't working label Nov 14, 2023
@Hendler Hendler changed the title Cannot parse f-string. print(f"{a}. {n} ({dt.strftime("%Y-%m-%d-%H:%M:%S")})") Cannot parse f-string. Nov 14, 2023
@JelleZijlstra
Copy link
Collaborator

Duplicate of #3746. Note this syntax is new in Python 3.12.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants