You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running black on this it would by default provide:
$ black --diff a.py
--- a.py 2024-04-19 01:29:28.562943+00:00
+++ a.py 2024-04-19 01:29:52.064944+00:00
@@ -1,4 +1,5 @@
import numpy as np
-a=np.arange(9).reshape((3,3))
-print(a[1,2])
+
+a = np.arange(9).reshape((3, 3))
+print(a[1, 2])
print(f"a[1,2] = {a[1,2]}")
would reformat a.py
All done! ✨ 🍰 ✨
1 file would be reformatted.
You can see the final two print statements are inconsistent formatting now. The first has inserted a space after the comma in a[1,2], but, the f-string has not adjusted the formatting of {a[1,2]} to be {a[1, 2]}.
If I accept the formatting black suggests, and then run flake8 on the same piece of code, flake8 will complain about the lack of a space after the comma in the f-string.
$ black a.py
reformatted a.py
All done! ✨ 🍰 ✨
1 file reformatted.
$ flake8 a.py
a.py:5:22: E231 missing whitespace after ','
Describe the solution you'd like
Formatting applied to code outside of f-strings should also apply to the code within the {..} in the f-strings.
Describe alternatives you've considered
Disable that warning in flake8.
Additional context
N/A.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Consider a simple python script:
Running black on this it would by default provide:
You can see the final two print statements are inconsistent formatting now. The first has inserted a space after the comma in
a[1,2]
, but, the f-string has not adjusted the formatting of{a[1,2]}
to be{a[1, 2]}
.If I accept the formatting black suggests, and then run flake8 on the same piece of code, flake8 will complain about the lack of a space after the comma in the f-string.
Describe the solution you'd like
Formatting applied to code outside of f-strings should also apply to the code within the
{..}
in the f-strings.Describe alternatives you've considered
Disable that warning in flake8.
Additional context
N/A.
The text was updated successfully, but these errors were encountered: