Skip to content

Commit

Permalink
added parseable line number and col number
Browse files Browse the repository at this point in the history
  • Loading branch information
cibinmathew committed Jul 10, 2022
1 parent 7af77d1 commit e8c18e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def reformat_code(
except Exception as exc:
if report.verbose:
traceback.print_exc()
report.failed(path, str(exc))
report.failed(path, None, None, str(exc))


# diff-shades depends on being to monkeypatch this function to operate. I know it's
Expand Down Expand Up @@ -755,7 +755,7 @@ def reformat_one(
except Exception as exc:
if report.verbose:
traceback.print_exc()
report.failed(src, str(exc))
report.failed(src, None, None, str(exc))


# diff-shades depends on being to monkeypatch this function to operate. I know it's
Expand Down Expand Up @@ -861,7 +861,7 @@ async def schedule_formatting(
if task.cancelled():
cancelled.append(task)
elif task.exception():
report.failed(src, str(task.exception()))
report.failed(src, None, None, str(task.exception()))
else:
changed = Changed.YES if task.result() else Changed.NO
# If the file was written back or was successfully checked as
Expand Down
8 changes: 6 additions & 2 deletions src/black/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def done(self, src: Path, changed: Changed) -> None:
out(msg, bold=False)
self.same_count += 1

def failed(self, src: Path, message: str) -> None:
def failed(self, src: Path, lineno: int, column: int, message: str) -> None:
"""Increment the counter for failed reformatting. Write out a message."""
err(f"error: cannot format {src}: {message}")
if lineno and column:
path_line_col=f"{src}:{lineno}:{column}"
else:
path_line_col=f"{src}"
err(f"error: cannot format {path_line_col}: {message}")
self.failure_count += 1

def path_ignored(self, path: Path, message: str) -> None:
Expand Down

0 comments on commit e8c18e3

Please sign in to comment.