From 06e95b1e9bcd43c4574840f8174ba4b2c5d281bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Mon, 23 Apr 2018 12:00:03 -0700 Subject: [PATCH] Show full path on diffs Fixes #130 --- README.md | 2 ++ black.py | 4 ++-- tests/test_black.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d10a86..9685172 100644 --- a/README.md +++ b/README.md @@ -518,6 +518,8 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * generalized star expression handling, including double stars; this 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 function parameters (#2) diff --git a/black.py b/black.py index dd2e2d1..eafc9e7 100644 --- a/black.py +++ b/black.py @@ -341,8 +341,8 @@ def format_file_in_place( with open(src, "w", encoding=src_buffer.encoding) as f: f.write(dst_contents) elif write_back == write_back.DIFF: - src_name = f"{src.name} (original)" - dst_name = f"{src.name} (formatted)" + src_name = f"{src} (original)" + dst_name = f"{src} (formatted)" diff_contents = diff(src_contents, dst_contents, src_name, dst_name) if lock: lock.acquire() diff --git a/tests/test_black.py b/tests/test_black.py index ba834c5..6f0ffa3 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -200,7 +200,7 @@ class BlackTestCase(unittest.TestCase): self.assertTrue(ff(tmp_file, write_back=black.WriteBack.DIFF)) sys.stdout.seek(0) actual = sys.stdout.read() - actual = actual.replace(tmp_file.name, "") + actual = actual.replace(str(tmp_file), "") finally: sys.stdout = hold_stdout os.unlink(tmp_file) -- 2.39.5