The latest (develop) version (tested at 394738e2a21737c23fdc67be399691341ca422fa) 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
this is what VSCode uses by default and breaks the "sort imports" feature if you upgrade to isort >= 5
This is fixed in the just released 5.1.1 version: https://github.com/timothycrosley/isort/releases/tag/5.1.1
Thanks for reporting!
~Timothy
Most helpful comment
this is what VSCode uses by default and breaks the "sort imports" feature if you upgrade to isort >= 5