Output something when no files are reformatted (#190)
Just executing ``black`` without any argument does not print any message to stdout or stderr. It's rather confusing, because the user doesn't know what happened. In ``len(sources) == 0`` case, black now prints ``No paths given. Nothing to do``. Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
8325f893b4
commit
2d9eaafa97
1
black.py
1
black.py
@ -192,6 +192,7 @@ def main(
|
|||||||
write_back = WriteBack.YES
|
write_back = WriteBack.YES
|
||||||
report = Report(check=check, quiet=quiet)
|
report = Report(check=check, quiet=quiet)
|
||||||
if len(sources) == 0:
|
if len(sources) == 0:
|
||||||
|
out("No paths given. Nothing to do 😴")
|
||||||
ctx.exit(0)
|
ctx.exit(0)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -636,6 +636,12 @@ def test_check_diff_use_together(self) -> None:
|
|||||||
)
|
)
|
||||||
self.assertEqual(result.exit_code, 1)
|
self.assertEqual(result.exit_code, 1)
|
||||||
|
|
||||||
|
def test_no_files(self) -> None:
|
||||||
|
with cache_dir():
|
||||||
|
# Without an argument, black exits with error code 0.
|
||||||
|
result = CliRunner().invoke(black.main, [])
|
||||||
|
self.assertEqual(result.exit_code, 0)
|
||||||
|
|
||||||
def test_read_cache_line_lengths(self) -> None:
|
def test_read_cache_line_lengths(self) -> None:
|
||||||
with cache_dir() as workspace:
|
with cache_dir() as workspace:
|
||||||
path = (workspace / "file.py").resolve()
|
path = (workspace / "file.py").resolve()
|
||||||
|
Loading…
Reference in New Issue
Block a user