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

Test the new isort extension #18997

Closed
3 tasks done
karthiknadig opened this issue Apr 25, 2022 · 2 comments
Closed
3 tasks done

Test the new isort extension #18997

karthiknadig opened this issue Apr 25, 2022 · 2 comments
Labels
testplan-item Test plan item/assignments for upcoming release
Milestone

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Apr 25, 2022

Refs: #18891

Complexity: 1

Create Issue


Requirements

Install the following extensions:
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

NOTE: Currently only pre-release version in available.

Verification

isort extension adds import organization support using the isort library. You should not have to install isort in your environment. Try this for example:

Create a python file with following code:

import unittest
import re
import sys
import atexit
import os
print('done')

You would see diagnostics like this:
image

You can trigger import sorting using shift+alt+o:
image
The first one there is from the prototype extension, the second one comes from python extension. Click on the first one.

Result should be something like this:

import atexit
import os
import re
import sys
import unittest

print('done')

You can add this to your settings to automatically do this for you and work with black formatter.

    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter"
    },
    "editor.codeActionsOnSave": { "source.organizeImports": true },
    "editor.formatOnSave": true,
    "isort.args": ["--profile", "black"]
@gregvanl
Copy link

@karthiknadig In the snippet above, shouldn't the setting be "isort.args": ["--profile", "black"]?

@karthiknadig
Copy link
Member Author

karthiknadig commented Apr 26, 2022

@gregvanl you are correct. I updated the snippet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testplan-item Test plan item/assignments for upcoming release
Projects
None yet
Development

No branches or pull requests

4 participants