Show full path on diffs

Fixes #130
This commit is contained in:
Łukasz Langa 2018-04-23 12:00:03 -07:00
parent 2e52a2b3ec
commit 06e95b1e9b
3 changed files with 5 additions and 3 deletions

View File

@ -518,6 +518,8 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
* generalized star expression handling, including double stars; this * generalized star expression handling, including double stars; this
fixes multiplication making expressions "unsafe" for trailing commas (#132) fixes multiplication making expressions "unsafe" for trailing commas (#132)
* fixed `--diff` not showing entire path (#130)
* fixed parsing of complex expressions after star and double stars in * fixed parsing of complex expressions after star and double stars in
function parameters (#2) function parameters (#2)

View File

@ -341,8 +341,8 @@ def format_file_in_place(
with open(src, "w", encoding=src_buffer.encoding) as f: with open(src, "w", encoding=src_buffer.encoding) as f:
f.write(dst_contents) f.write(dst_contents)
elif write_back == write_back.DIFF: elif write_back == write_back.DIFF:
src_name = f"{src.name} (original)" src_name = f"{src} (original)"
dst_name = f"{src.name} (formatted)" dst_name = f"{src} (formatted)"
diff_contents = diff(src_contents, dst_contents, src_name, dst_name) diff_contents = diff(src_contents, dst_contents, src_name, dst_name)
if lock: if lock:
lock.acquire() lock.acquire()

View File

@ -200,7 +200,7 @@ def test_expression_diff(self) -> None:
self.assertTrue(ff(tmp_file, write_back=black.WriteBack.DIFF)) self.assertTrue(ff(tmp_file, write_back=black.WriteBack.DIFF))
sys.stdout.seek(0) sys.stdout.seek(0)
actual = sys.stdout.read() actual = sys.stdout.read()
actual = actual.replace(tmp_file.name, "<stdin>") actual = actual.replace(str(tmp_file), "<stdin>")
finally: finally:
sys.stdout = hold_stdout sys.stdout = hold_stdout
os.unlink(tmp_file) os.unlink(tmp_file)