Skip to content

Commit

Permalink
[codemod] show errors from formatter subprocess call
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmylai committed Apr 23, 2020
1 parent 477a03e commit e5abaa8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libcst/codemod/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def invoke_formatter(formatter_args: Sequence[str], code: AnyStr) -> AnyStr:
formatter_args,
env={},
input=code,
stderr=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=not work_with_bytes,
encoding=None if work_with_bytes else "utf-8",
),
Expand All @@ -70,6 +70,9 @@ def print_execution_result(result: TransformResult) -> None:
print(f"WARNING: {warning}", file=sys.stderr)

if isinstance(result, TransformFailure):
error = result.error
if isinstance(error, subprocess.CalledProcessError):
print(error.output.decode("utf-8"), file=sys.stderr)
print(result.traceback_str, file=sys.stderr)


Expand Down

0 comments on commit e5abaa8

Please sign in to comment.