-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
"organize imports" is inconsistent depending on whether the file is saved or not #8245
Comments
Chances are the difference is when running isort on a saved file it is discovering its configuration file while an unsaved file buffer is being run in a temp directory and thus not in a place where isort will pick up its configuration file. |
Yep that was my guess in the OP as well ;) |
@jleclanche in the interest of reproducing this, what should I put in my tox.ini to reproduce the behavior? |
@ericsnowcurrently any mismatch works. This especially: [isort]
indent = tab
line_length = 88
balanced_wrapping = true
combine_as_imports = true
default_section = THIRDPARTY
ensure_newline_before_comments = true
include_trailing_comma=True
multi_line_output = 3
known_first_party = foo And then give a different import foo
import os
import django
from foo import bar
from django import baz And imports should be wildly inconsistent between saves. |
@jleclanche, I'll take a look as soon as I can. |
@ericsnowcurrently also please take a look at my comment here: #5840 (comment) |
I was able to verify that with an unsaved file I get: import os
import django
import foo
from django import baz
from foo import bar and with a saved file I get: import os
import django
from django import baz
import foo
from foo import bar We'll investigate further. |
Stumbled over this coming from issue #5840 @DonJayamanne suggested a fix there which would solve the issue here as well. |
Related: #4831
I have some isort config set up in
tox.ini
with a different configuration (specifically, a different set ofknown_first_party
) than the global one set up in vscode.The problem: If the file is not saved yet, "organize imports" will result in a different output (using the global isort config) than if the file is saved (using the project-wide one). The behaviour when the file is saved is the correct and expected one.
I suspect this happens because vscode runs isort on a temp file in a different directory when it's not saved.
The text was updated successfully, but these errors were encountered: