]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Output something when no files are reformatted (#190)
authorChristian Heimes <christian@python.org>
Mon, 7 May 2018 17:12:47 +0000 (19:12 +0200)
committerŁukasz Langa <lukasz@langa.pl>
Mon, 7 May 2018 17:12:47 +0000 (10:12 -0700)
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>
black.py
tests/test_black.py

index fdefb746de14fc28002c820e2a19454db5873298..f235afe60c7aa3545a16fd96c0e8d7a9459fa72b 100644 (file)
--- a/black.py
+++ b/black.py
@@ -192,6 +192,7 @@ def main(
         write_back = WriteBack.YES
     report = Report(check=check, quiet=quiet)
     if len(sources) == 0:
+        out("No paths given. Nothing to do 😴")
         ctx.exit(0)
         return
 
index 02926d1ae4a9fb5248390a35a2c57ceda8539f67..5e17faf1f5f6ee48c3e7e593984dd6d564b1c971 100644 (file)
@@ -636,6 +636,12 @@ class BlackTestCase(unittest.TestCase):
             )
             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:
         with cache_dir() as workspace:
             path = (workspace / "file.py").resolve()