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

black formatter not working when file contains several comments #4419

Closed
Kenza98 opened this issue Jul 30, 2024 · 4 comments
Closed

black formatter not working when file contains several comments #4419

Kenza98 opened this issue Jul 30, 2024 · 4 comments
Labels
T: bug Something isn't working

Comments

@Kenza98
Copy link

Kenza98 commented Jul 30, 2024

error message:
Oh no! 💥 💔 💥
1 file failed to reformat.


for i in range(N):
    for j in range(M):
        """conditions = [
        timestamps[i] is not None,
        not np.isnan(depth[j]),
        not np.isnan(lats[i]),
        not np.isnan(longs[i]),
        not np.isnan(temperature[i, j])
]
if all(conditions):
"""
        list_temp_measures.append(
            {
                # assert
                "timestamp": timestamps[i].isoformat(),
                "depth": floatdepth[j],
                "latitude": lats[i],
                "longitude": longs[i],
                "temperature": temperature[i, j],
            }
        )

This works though:


"""conditions = [
        timestamps[i] is not None,
        not np.isnan(depth[j]),
        not np.isnan(lats[i]),
        not np.isnan(longs[i]),
        not np.isnan(temperature[i, j])]
if all(conditions):
"""

for i in range(N):
    for j in range(M):

        list_temp_measures.append({
                # assert
                "timestamp": timestamps[i].isoformat(),
                "depth": floatdepth[j],
                "latitude": lats[i],
                "longitude": longs[i],
                "temperature": temperature[i, j],}
        )


---output msg:
All done! ✨ 🍰 ✨
1 file reformatted.

and gives :


for i in range(N):
    for j in range(M):

        list_temp_measures.append(
            {
                # assert
                "timestamp": timestamps[i].isoformat(),
                "depth": floatdepth[j],
                "latitude": lats[i],
                "longitude": longs[i],
                "temperature": temperature[i, j],
            }
        )


@Kenza98 Kenza98 added the T: bug Something isn't working label Jul 30, 2024
@JelleZijlstra
Copy link
Collaborator

You first sample looks like it has a syntax error in it.

@JelleZijlstra
Copy link
Collaborator

That's not true, I misread the code. However, I can't reproduce a crash on Black 24.4.2 and Python 3.12.

@Kenza98
Copy link
Author

Kenza98 commented Jul 30, 2024 via email

@JelleZijlstra
Copy link
Collaborator

This looks like the issue fixed by #4290 in version 24.4.0, are you on the latest release?

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

3 participants