Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--diff broken when reading from standard input #1189

Closed
PeterJCLaw opened this issue May 5, 2020 · 2 comments
Closed

--diff broken when reading from standard input #1189

PeterJCLaw opened this issue May 5, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@PeterJCLaw
Copy link

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
@c4urself
Copy link

this is what VSCode uses by default and breaks the "sort imports" feature if you upgrade to isort >= 5

@timothycrosley
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants