Repository: timothycrosley/isort
Pull request #884 (2019-03-06 14:55:18)

Do not print file names when in the quiet mode
The current help for the `--quiet` option says that it enables "extra
quiet output, only errors are outputted".  However, isort still prints
`Fixing spam/eggs.py` messages to stdout.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97a68a00..d4b66cae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,10 +11,7 @@ Internal:
 Planned:
   - profile support for common project types (black, django, google, etc)
 
-### 4.3.12 - March 6, 2019 - hot fix release
-- Fix error caused when virtual environment not detected
-
-### 4.3.11 - March 6, 2019 - hot fix release
+### 4.3.11 - March 3, 2019 - hot fix release
 - Fixed issue #876: confused by symlinks pointing to virtualenv gives FIRSTPARTY not THIRDPARTY
 - Fixed issue #873: current version skips every file on travis
 - Additional caching to reduce performance regression introduced in 4.3.5
diff --git a/isort/__init__.py b/isort/__init__.py
index 342606e8..e3af789b 100644
--- a/isort/__init__.py
+++ b/isort/__init__.py
@@ -22,4 +22,4 @@ OTHER DEALINGS IN THE SOFTWARE.
 from . import settings  # noqa: F401
 from .isort import SortImports  # noqa: F401
 
-__version__ = "4.3.12"
+__version__ = "4.3.10"
diff --git a/isort/finders.py b/isort/finders.py
index dcfaf8a6..11f481ab 100644
--- a/isort/finders.py
+++ b/isort/finders.py
@@ -128,8 +128,7 @@ class PathFinder(BaseFinder):
 
         # virtual env
         self.virtual_env = self.config.get('virtual_env') or os.environ.get('VIRTUAL_ENV')
-        if self.virtual_env:
-            self.virtual_env = os.path.realpath(self.virtual_env)
+        self.virtual_env = os.path.realpath(self.virtual_env)
         self.virtual_env_src = ''
         if self.virtual_env:
             self.virtual_env_src = '{0}/src/'.format(self.virtual_env)
diff --git a/isort/isort.py b/isort/isort.py
index 73363e83..0d8d6f09 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -212,7 +212,8 @@ class SortImports(object):
                     if answer in ('quit', 'q'):
                         sys.exit(1)
             with open(self.file_path, 'w', encoding=self.file_encoding, newline='') as output_file:
-                print("Fixing {0}".format(self.file_path))
+                if not self.config['quiet']:
+                    print("Fixing {0}".format(self.file_path))
                 output_file.write(self.output)
 
     @property
diff --git a/setup.py b/setup.py
index 4e798eed..3a4360b7 100755
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ with open('README.rst') as f:
     readme = f.read()
 
 setup(name='isort',
-      version='4.3.12',
+      version='4.3.10',
       description='A Python utility / library to sort Python imports.',
       long_description=readme,
       author='Timothy Crosley',


Test patch:
diff --git a/test_isort.py b/test_isort.py
index 999f1a1e..bfc89ff9 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -2740,6 +2740,22 @@ def test_command_line(tmpdir, capfd, multiprocess):
         assert str(tmpdir.join("file2.py")) in out
 
 
+@pytest.mark.parametrize("quiet", (False, True))
+def test_quiet(tmpdir, capfd, quiet):
+    if sys.platform.startswith("win"):
+        return
+    from isort.main import main
+    tmpdir.join("file1.py").write("import re\nimport os")
+    tmpdir.join("file2.py").write("")
+    arguments = ["-rc", str(tmpdir)]
+    if quiet:
+        arguments.append("-q")
+    main(arguments)
+    out, err = capfd.readouterr()
+    assert not err
+    assert bool(out) != quiet
+
+
 @pytest.mark.parametrize('enabled', (False, True))
 def test_safety_excludes(tmpdir, enabled):
     tmpdir.join("victim.py").write("# ...")