From 86d7b341eabe420734bf4596e32fa28e2d83071e Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 21 Dec 2021 16:33:40 +0530 Subject: [PATCH 1/7] Added decent coloring --- src/black/report.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/black/report.py b/src/black/report.py index 7e1c8b4b87f..35016edced3 100644 --- a/src/black/report.py +++ b/src/black/report.py @@ -93,12 +93,16 @@ def __str__(self) -> str: if self.change_count: s = "s" if self.change_count > 1 else "" report.append( - style(f"{self.change_count} file{s} {reformatted}", bold=True) + style(f"{self.change_count} file{s} ", bold=True, fg="blue") + + style(f"{reformatted}", bold=True) ) + if self.same_count: s = "s" if self.same_count > 1 else "" - report.append(f"{self.same_count} file{s} {unchanged}") + report.append( + style(f"{self.same_count} file{s} ", fg="blue") + f"{unchanged}" + ) if self.failure_count: s = "s" if self.failure_count > 1 else "" report.append(style(f"{self.failure_count} file{s} {failed}", fg="red")) - return ", ".join(report) + "." + return ", ".join(report) + "." \ No newline at end of file From accbd54b62df174e90ac62eba6915ffe4cff3728 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 22 Dec 2021 00:32:21 +0530 Subject: [PATCH 2/7] Newline before final message and formatting fixes --- src/black/__init__.py | 1 + src/black/report.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index d8b98196aa0..7b11e1e15e2 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -494,6 +494,7 @@ def main( workers=workers, ) + out() if verbose or not quiet: out(error_msg if report.return_code else "All done! ✨ 🍰 ✨") if code is None: diff --git a/src/black/report.py b/src/black/report.py index 35016edced3..844eb07fdba 100644 --- a/src/black/report.py +++ b/src/black/report.py @@ -105,4 +105,4 @@ def __str__(self) -> str: if self.failure_count: s = "s" if self.failure_count > 1 else "" report.append(style(f"{self.failure_count} file{s} {failed}", fg="red")) - return ", ".join(report) + "." \ No newline at end of file + return ", ".join(report) + "." From 9b66826cc0d15ddfaafbf6bf25797e6372e96f17 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 22 Dec 2021 00:35:29 +0530 Subject: [PATCH 3/7] Changelog Entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 0452f1820c4..559b6629810 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - Tuple unpacking on `return` and `yield` constructs now implies 3.8+ (#2700) - Unparenthesized tuples on annotated assignments (e.g `values: Tuple[int, ...] = 1, 2, 3`) now implies 3.8+ (#2708) +- Text coloring added in the final statistics of files modifications (#2711) ## 21.12b0 From fc40e78dbf9ce69cd72934b6d9c2dac7d91bd4f3 Mon Sep 17 00:00:00 2001 From: VanSHOE <75690289+VanSHOE@users.noreply.github.com> Date: Wed, 22 Dec 2021 00:38:37 +0530 Subject: [PATCH 4/7] Accepted fix Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com> --- src/black/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 7b11e1e15e2..fedebb3f691 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -494,8 +494,8 @@ def main( workers=workers, ) - out() if verbose or not quiet: + out() out(error_msg if report.return_code else "All done! ✨ 🍰 ✨") if code is None: click.echo(str(report), err=True) From c0cf2f0868f2622c7269c1a9f48b7293fd6a73b5 Mon Sep 17 00:00:00 2001 From: VanSHOE <75690289+VanSHOE@users.noreply.github.com> Date: Wed, 22 Dec 2021 00:49:52 +0530 Subject: [PATCH 5/7] Fixed changelog entry --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 559b6629810..3ed7969367d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,7 +14,7 @@ - Tuple unpacking on `return` and `yield` constructs now implies 3.8+ (#2700) - Unparenthesized tuples on annotated assignments (e.g `values: Tuple[int, ...] = 1, 2, 3`) now implies 3.8+ (#2708) -- Text coloring added in the final statistics of files modifications (#2711) +- Text coloring added in the final statistics (#2712) ## 21.12b0 From 6c98632fe32ad00a0eb993cf3fbd011579d25588 Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Fri, 24 Dec 2021 22:21:11 -0500 Subject: [PATCH 6/7] --code is special and shouldn't be touched --- src/black/__init__.py | 3 ++- src/black/report.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index fedebb3f691..67122f01f0c 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -495,7 +495,8 @@ def main( ) if verbose or not quiet: - out() + if code is None: + out() out(error_msg if report.return_code else "All done! ✨ 🍰 ✨") if code is None: click.echo(str(report), err=True) diff --git a/src/black/report.py b/src/black/report.py index 844eb07fdba..43b942c9e3c 100644 --- a/src/black/report.py +++ b/src/black/report.py @@ -99,9 +99,7 @@ def __str__(self) -> str: if self.same_count: s = "s" if self.same_count > 1 else "" - report.append( - style(f"{self.same_count} file{s} ", fg="blue") + f"{unchanged}" - ) + report.append(style(f"{self.same_count} file{s} ", fg="blue") + unchanged) if self.failure_count: s = "s" if self.failure_count > 1 else "" report.append(style(f"{self.failure_count} file{s} {failed}", fg="red")) From 8ada34f356dc84fdfaa483bbe05d8949abe3d886 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 31 Dec 2021 14:08:07 +0530 Subject: [PATCH 7/7] Accepted fix for spacing --- src/black/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 67122f01f0c..b95bc1264c1 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -495,7 +495,7 @@ def main( ) if verbose or not quiet: - if code is None: + if code is None and (verbose or report.change_count or report.failure_count): out() out(error_msg if report.return_code else "All done! ✨ 🍰 ✨") if code is None: