-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run Isort when formatOnSave is on #156
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
Run Isort when formatOnSave is on #156
Comments
Unfortunately, not at this stage. Will look into this later as a feature request. |
From @eMerzh on August 5, 2017 12:22 Thanks a lot :) i'll follow the updates ;) |
From @threaz on August 23, 2017 19:24 Is there any other way to run your |
We might consider adding this is someone submitted a PR that added a flag to also do import sorts as part of document formatting. |
@brettcannon I'd like to submit a PR to add this feature but I'm not yet familiar with the codebase. Do you have any pointers to get me started? |
What would be the best way to implement this in your opinion? 1 - One option would be to take one step further in the promise of provideDocumentFormattingEdits:
I know there's a lot together there, but if you think it's a possible way so I can improve it and make a PR. This proposed code works, I ran a test locally and it made both of the formatting correctly. 2 - Another option would be to transform the "python.formatting.provider" configuration into an array and it execute all the formats in sequence. ["autopep8", "isort"]. The problem here would be the mandatory change in who already uses the setting as a string. |
@ricardochaves Import sorting is basically the only thing that people would potentially want to stack with other formatters, so I don't think making the support generic makes sense. |
Perfect @brettcannon, and what do you think of this solution? New method in
In the format chain, after it applies the defined formatter, we call the new method:
|
@ricardochaves |
I think we need to take a closer look at this. Please look at https://code.visualstudio.com/updates/v1_23#_run-code-actions-on-save |
Hi @DonJayamanne , What do you think of this solution? On sortImports.ts (/Users/ricardochaves/Desktop/projetos/vscode-python/src/client/sortImports.ts):
An extremely simple code. Using the |
@ricardochaves I'd like to ensure sorting of imports within the python extension is implemented the way it is implemented in other languages (see above link). |
From @eMerzh on August 5, 2017 10:39
Hi,
many many thanks for this extension, it's really great.
I use format on save and been pretty happy about it.
But I also wanted to do Isort on save, could it be possible to add both of the tools or smth ?
Thanks a lot
Copied from original issue: DonJayamanne/pythonVSCode#1140
The text was updated successfully, but these errors were encountered: