From 7431db7744ca858e8b6787b571c66c5140582918 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Wed, 9 Sep 2020 20:52:20 -0700 Subject: [PATCH] Fixed #1469: --diff option is ignored when input is from stdin. Release hot fix release 5.5.2 --- CHANGELOG.md | 3 +++ isort/_version.py | 2 +- isort/main.py | 1 + pyproject.toml | 2 +- tests/unit/test_main.py | 17 +++++++++++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c504a2fb..f6a0ce5a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Changelog NOTE: isort follows the [semver](https://semver.org/) versioning standard. Find out more about isort's release policy [here](https://pycqa.github.io/isort/docs/major_releases/release_policy/). +### 5.5.2 [Hotfix] September 9, 2020 + - Fixed #1469: --diff option is ignored when input is from stdin. + ### 5.5.1 September 4, 2020 - Fixed #1454: Ensure indented import sections with import heading and a preceding comment don't cause import sorting loops. - Fixed #1453: isort error when float to top on almost empty file. diff --git a/isort/_version.py b/isort/_version.py index f680f9ffe..9fe27eebf 100644 --- a/isort/_version.py +++ b/isort/_version.py @@ -1 +1 @@ -__version__ = "5.5.1" +__version__ = "5.5.2" diff --git a/isort/main.py b/isort/main.py index e7dc61ad5..5dc2ef188 100644 --- a/isort/main.py +++ b/isort/main.py @@ -836,6 +836,7 @@ def main(argv: Optional[Sequence[str]] = None, stdin: Optional[TextIOWrapper] = input_stream=sys.stdin if stdin is None else stdin, output_stream=sys.stdout, config=config, + show_diff=show_diff, ) else: skipped: List[str] = [] diff --git a/pyproject.toml b/pyproject.toml index 3aff16105..31e126565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ line-length = 100 [tool.poetry] name = "isort" -version = "5.5.1" +version = "5.5.2" description = "A Python utility / library to sort Python imports." authors = ["Timothy Crosley "] license = "MIT" diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index ae63fd607..2457f2cb1 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -165,6 +165,23 @@ def test_main(capsys, tmpdir): """ ) + # Should be able to stream diff + input_content = TextIOWrapper( + BytesIO( + b""" +import b +import a +""" + ) + ) + main.main(config_args + ["-", "--diff"], stdin=input_content) + out, error = capsys.readouterr() + assert not error + assert "+" in out + assert "-" in out + assert "import a" in out + assert "import b" in out + # Should be able to run with just a file python_file = tmpdir.join("has_imports.py") python_file.write(