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

Report all stacktraces in verbose mode #3938

Merged
merged 6 commits into from Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -42,6 +42,8 @@

- Black no longer attempts to provide special errors for attempting to format Python 2
code (#3933)
- Black will more consistently print stacktraces on internal errors in verbose mode
(#3938)

### _Blackd_

Expand Down
7 changes: 6 additions & 1 deletion src/black/concurrency.py
Expand Up @@ -9,6 +9,7 @@
import os
import signal
import sys
import traceback
from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor
from multiprocessing import Manager
from pathlib import Path
Expand Down Expand Up @@ -171,7 +172,11 @@ async def schedule_formatting(
if task.cancelled():
cancelled.append(task)
elif task.exception():
report.failed(src, str(task.exception()))
exc = task.exception()
assert exc is not None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a walrus so you can avoid the assert?

elif exc := task.exception():

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, we dropped 3.7

if report.verbose:
traceback.print_exception(type(exc), exc, exc.__traceback__)
report.failed(src, str(exc))
else:
changed = Changed.YES if task.result() else Changed.NO
# If the file was written back or was successfully checked as
Expand Down