-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
isort not honoring setup.cfg #5840
Comments
After some more research, I was able to fix this issue by adding "python.sortImports.args": ["--settings-path=${workspaceFolder}/setup.cfg"] to my user settings as suggested here. This feels a little bit hacky tough, since not all projects use a Is there a better way to handle this with less manual configuration? |
Prescribed Solution
|
The real cause of this is that the bundled Formatter invocations do set cwd properly, so I guess the solution would be to copy their cwd behaviour (maybe extract common parts even?). I hope to get around trying that soon. @DonJayamanne I get the reasoning behind the On a related note - is there a reason you guys bundle your own |
I'm facing a related issue. I've configured isort's
and since I would be great @DonJayamanne if like you mentioned you could generate the temp file in the directory of the file. Then I wouldn't lose the directory context and apply my |
Any update on a fix for this? Its still happening in 1.44.2 and this issue has been open for nearly a year. |
Also experiencing this with configuration in |
This is NOT still an issue after #9128. I believe this PR was included since 2020.6.88468 and pyproject.toml is working for me. EDIT: It's working, after I configured it correctly. |
I'm still curious if there's an answer to @mikeroll's question:
|
For me, this is not yet fixed. {
"python.sortImports.path": "${workspaceFolder}\\.venv\\Scripts\\isort.exe",
"python.sortImports.args": [
"--settings-path=${workspaceFolder}/setup.cfg"
],
} otherwise any isort configs in VSCode 1.49.0 insider |
Environment data
Issue
I added
to my user settings to sort imports with
isort
. I'm also usingblack
as a code formatter. On multiline imports these two tools format imports very differently, leading to alternating formatting and jumping code from one save to the next as shown in this gif.I was able to prevent this by configuring
isort
to useblack
's formatting by adding[isort] multi_line_output = 3 include_trailing_comma = True
to my
setup.cfg
as indicated in the comments of this black commit.Now, the file is stable if I repeatedly save it without changes in between. But if I modify the file and then save, the imports briefly flash to
isort
formatting before reverting toblack
formatting. So unlike before, the final result is now alwaysblack
formatting but there's jumping code every time I modify and save.This seems to suggest that
isort
is still being run by VS Code with its default settings when theformatOnSave
callbacks are triggered. Is there any way to respect thesetup.cfg
settings in theisort
callback?Additional Info
Related Issue: #2301
The text was updated successfully, but these errors were encountered: