Skip to content

Commit

Permalink
Report all stacktraces in verbose mode (#3938)
Browse files Browse the repository at this point in the history
Previously these were swallowed (unlike the ones in black/__init__.py)
  • Loading branch information
hauntsaninja authored Oct 10, 2023
1 parent 5d5bf6e commit 7aa37ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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: 5 additions & 2 deletions src/black/concurrency.py
Original file line number Diff line number Diff line change
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 @@ -170,8 +171,10 @@ async def schedule_formatting(
src = tasks.pop(task)
if task.cancelled():
cancelled.append(task)
elif task.exception():
report.failed(src, str(task.exception()))
elif exc := task.exception():
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

0 comments on commit 7aa37ea

Please sign in to comment.