The latest (develop) version (tested at 394738e) of isort appears to have regressed the handling of --diff when reading from standard input (originally fixed by #384 in the 4.x series).
--diff support with stdin is important to allow editor integrations to use isort on modified files and unsaved buffers as otherwise the editor would need to duplicate isort's locating of configuration files.
$ cat demo.py
import os, sys, collections
$ isort --diff - < demo.py
Traceback (most recent call last):
File "/home/peter/.virtualenvs/isort/bin/isort", line 11, in <module>
load_entry_point('isort', 'console_scripts', 'isort')()
File "/home/play/isort/isort/main.py", line 600, in main
**arguments,
File "/home/play/isort/isort/api.py", line 104, in sorted_imports
config = _config(path=file_path, config=config, **config_kwargs)
File "/home/play/isort/isort/api.py", line 47, in _config
config = Config(**config_kwargs)
File "/home/play/isort/isort/settings.py", line 300, in __init__
super().__init__(sources=tuple(sources), **combined_config) # type: ignore
TypeError: __init__() got an unexpected keyword argument 'show_diff'
Perhaps surprisingly --diff works fine when given actual filenames:
$ isort --diff demo.py
--- /tmp/isort-bug/demo.py:before 2020-05-05 22:00:57.723864
+++ /tmp/isort-bug/demo.py:after 2020-05-05 22:04:46.469076
@@ -1 +1,3 @@
-import os, sys, collections
+import os
+import sys
+import collections
Fixing /tmp/isort-bug/demo.py
The latest (
develop) version (tested at 394738e) ofisortappears to have regressed the handling of--diffwhen reading from standard input (originally fixed by #384 in the 4.x series).--diffsupport with stdin is important to allow editor integrations to useisorton modified files and unsaved buffers as otherwise the editor would need to duplicateisort's locating of configuration files.Perhaps surprisingly
--diffworks fine when given actual filenames: