Closed godtang closed 1 day ago
@godtang This is coming from Black itself. Does it work when you try to format it from command line?
@godtang This is coming from Black itself. Does it work when you try to format it from command line?
sorry , i don't know how to format from command line
i try it, and black work
What is the version of black where it worked? python -m black —version
should tell you.
What is the version of black where it worked?
python -m black —version
should tell you.
python.exe -m black --version python -m black, 24.4.2 (compiled: yes) Python (CPython) 3.12.4
Hey @godtang ! I think I've discovered how to resolve your issue: could you try to replace the double-quotes with single-quotes inside your f-string curly braces (i.e. inside your call to now.strftime()
)?
In my use-case:
2024-07-17 18:18:39.086 [info] error: cannot format XXXXXXX: Cannot parse: 398:34: f"|{data.get("infilename"):<{infilename_len}}"
Oh no! 💥 💔 💥
1 file failed to reformat.
After changing inner double-quotes to single-quotes:
outfile.write(
f"|{data.get('infilename'):<{infilename_len}}"
...
)
Both the VSCode black
extension (ms-python.black-formatter
ships with black=24.3.0.
) and black, 24.4.2
now succeed:
2024-07-17 18:32:19.912 [info] reformatted XXXXXX
All done! ✨ 🍰 ✨
1 file reformatted.
Closing this, since the build in black
is updated in the pre-release to latest.
Diagnostic Data
Behaviour
Expected Behavior
reformatted succ
Actual Behavior
Cannot parse
Reproduction Steps:
Logs:
Click here for detailed logs
2024-06-11 15:38:40.561 [info] error: cannot format xxxxx.py: Cannot parse: 219:52: xxxx = f"TEST{now.strftime("%Y%m%d%H%M%S")}{random.randint(1,9999):0>4}" Oh no! 💥 💔 💥 1 file failed to reformat.Outcome When Attempting Debugging Steps:
Did running it from the command line work?
Extra Details